facebookarchive / fb-caffe-exts

Some handy utility libraries and tools for the Caffe deep learning framework.
Other
457 stars 154 forks source link

python errors #3

Closed szagoruyko closed 8 years ago

szagoruyko commented 8 years ago

I've got two problems trying to use torch2caffe, one is in the beginning when I run

th torch2caffe/torch2caffe.lua

I have

ImportError: No module named torch2caffe.lib_py

no matter how I mess with PYTHONPATH

Then, if I just modify it to work from torch2caffe folder I've got more interesting:

Traceback (most recent call last):
  File "/opt/rocks/fb-caffe-exts/torch2caffe/lib_py.py", line 17, in <module>
    import caffe
  File "/opt/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
  File "/opt/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: dlopen: cannot load any more object with static TLS

any ideas? thanks

szagoruyko commented 8 years ago

oh exactly the same issue as https://github.com/facebook/fb-caffe-exts/issues/2, closing this one although it doesnt help me much

ajtulloch commented 8 years ago

@szagoruyko For 2) does vanilla pycaffe work when you import caffe from Python? I wonder if it's fb.python specific or prexisting. For 1) I guess just adding a __init__.py in torch2caffe/ should fix the import issue, (fbconfig/fbmake inserts those __init__.py files automatically).

szagoruyko commented 8 years ago

thanks Andrew, __init__.py helped with 1), didnt know that. Adding LD_PRELOAD with libcaffe.so solved the other issue, dont know why though. So if anyone else has issues that's thats what I had to do run it:

sed -i.bak 's/local logging/-- local logging/' torch2caffe/*lua
sed -i.bak 's/logging\.infof/print/' torch2caffe/*lua
sed -i.bak 's/logging\.info/print/' torch2caffe/*lua
sed -i.bak 's/logging\.errorf/error/' torch2caffe/*lua
sed -i.bak 's/logging\.fatalf/error/' torch2caffe/*lua
ajtulloch commented 8 years ago

Thanks for the detailed info @szagoruyko, I don't understand why LD_PRELOAD'ing libcaffe.so is necessary, I wonder if there's something internal in fbcode that is masking this.

XiaozhiChen commented 8 years ago

Hi guys,

I added torch2caffe/__init__.py, but still got the error:

ImportError: No module named torch2caffe.lib_py

Then I modified it to run from torch2caffe folder, the error still exist:

ImportError: No module named lib_py

For a minimal case as below:

local py = require('fb.python')
local ny = py.import('numpy')
local t2c = py.import('lib_py')

local ny = py.import('numpy') works but t2c = py.import('lib_py') fails.

Any hints on that?

Thanks!