Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

python errors #3

Closed
szagoruyko opened this issue Feb 17, 2016 · 5 comments
Closed

python errors #3

szagoruyko opened this issue Feb 17, 2016 · 5 comments

Comments

@szagoruyko
Copy link

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
Copy link
Author

oh exactly the same issue as #2, closing this one although it doesnt help me much

@ajtulloch
Copy link
Contributor

@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
Copy link
Author

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:

  • touch torch2caffe/__init__.py
  • sed to get rid of logging
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
  • add LD_PRELOAD=.../libcaffe.so
  • add PYTHONPATH=$PYTHONPATH:.../caffe/python:.../fb-caffe-exts

@ajtulloch
Copy link
Contributor

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
Copy link

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants