Can not import caffe and pytorch at the same time

import caffe first:

>>> import caffe                                                                                                                        
>>> import torch   
File "<stdin>", line 1, in <module>
File "/home/name/anaconda3/lib/python3.6/site-packages/torch/", line 53, in <module>
    from torch._C import *                                                                           
ImportError: dlopen: cannot load any more object with static TLS

import torch first:

>>> import torch
>>> import caffe  
Segmentation fault (core dumped)

My pytorch version is 0.2.0, which is old but I must use this version because I want to convert a pytorch model to caffemodel. Anyone knows how to solve this problem?

The first error is just that both libraries are really big and require too many C functions. You can look for the error message on google. That also happens quite often with matlab for example when you try and load big libraries.

The second one is a problem with caffe I guess, or pytorch loading some library that caffe does not expect and makes it crash.

Thank you. I have solved the second problem simply by switching python from 3.6 to 2.7.