0
votes

I cannot import caffe into (anaconda-) python. I'm following a notebook example on "logistic regression on non-image HDF5 data". When I execute the line

import caffe

I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-17-3524921938b5> in <module>()
      8 sys.path.insert(0, caffe_root + 'python')
      9 
---> 10 import caffe
     11 

/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver
      2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver
      3 from .proto.caffe_pb2 import TRAIN, TEST
      4 from .classifier import Classifier
      5 from .detector import Detector

/home/myName/libs/caffe/caffe-master-anaconda-python/python/caffe/pycaffe.py in <module>()
     11 import numpy as np
     12 
---> 13 from ._caffe import Net, SGDSolver
     14 import caffe.io
     15 

ImportError: libjpeg.so.62: cannot open shared object file: No such file or directory

The library libjpeg.so.62 is definetly installed under /usr/lib/i386-linux-gnu/libjpeg.so.62. I don't know what is going wrong here or how to tell anacondapython where to look for libjpeg.so.62.

I already tried out sudo apt-get install libjpeg62:i386 but apt-get says "libjpeg62:i386 is already the newest version. libjpeg62:i386 set to manually installed."

I compiled caffe while modifying "Makefile.config" such that it was pointing it to the ananconda python path. I also exported the PYTHONPATH and PATH of my anaconda directory:

export PATH="/home/myName/libs/anaconda/bin:$PATH"
export PYTHONPATH="/home/myName/libs/caffe/caffe-master-anaconda-python/python:$PYTHONPATH"
1

1 Answers

0
votes

Ok I finally found the solution:

I had to sudo apt-get install libjpeg62

After that a new error occurred while trying to import caffe, namely

ImportError: /home/myName/libs/anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libx264.so.142)

That could be solved by removing some buggy anaconda libraries thus resorting to the system libraries,quote shelhamer: "Some versions of Anaconda seem to come with a bad libm. rm ~/anaconda/lib/libm.* takes care of this by reverting to the system libm."

see github bvlc