Problem in "Import Caffe" in Python wrapper

818 views
Skip to first unread message

raj...@mail.fresnostate.edu

unread,
Jan 25, 2017, 8:14:10 PM1/25/17
to Caffe Users
Hi,
I'm new to Caffe sorry if i ask some simple questions sorry for that but its a learning process for me. 
I have followed all the steps according to Caffe website.
make clean - Pass
make all - Pass
make pycaffe - Pass
set the path
export PYTHONPATH=/home/rajathmb/caffe/caffe/python
make distribute

I'm trying to import caffe in python wrapper i am getting this error could anyone please help me and let me know if i have made any mistakes 

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rajathmb/caffe/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/rajathmb/caffe/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

A small snippet 

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
# You should not set this flag if you will be reading LMDBs with any
# possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
#BLAS_INCLUDE := /path/to/your/blas
#BLAS_LIB := /path/to/your/blas

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
#ANACONDA_HOME := $(HOME)/anaconda
#PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
#$(ANACONDA_HOME)/include/python2.7 \
#$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
#PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
PYTHON_LIB += $(shell brew --prefix numpy)/lib

 
 

Przemek D

unread,
Jan 26, 2017, 4:21:31 AM1/26/17
to Caffe Users
Python can't find CUDA. I'm assuming you're running under linux. Please cd to caffe directory and post the output of
ldd caffe
this will show where your system looks for shared libraries that the executable needs.

raj...@mail.fresnostate.edu

unread,
Jan 26, 2017, 12:18:30 PM1/26/17
to Caffe Users
Hi Przemek,
Thank you very much for your response. I really appreciate your efforts to help me resolve the problem. I did try your command but I'm sorry i did not get any output.

I'm using Virtual-box to run Ubuntu 14.04 and prior to this i had installed and run the Cafffe succesfully on linux machine but it was a low configuration system. So i switched to a high configuration system but now it is not working. Kindly help me in resolving this issue.

rajathmb@rajathmb-VirtualBox:~/caffe/caffe$ ls

build       CMakeLists.txt   data        docs      INSTALL.md  Makefile~         Makefile.config.example  python     src
caffe.cloc  CONTRIBUTING.md  distribute  examples  LICENSE     Makefile.config   matlab                   README.md  tools
cmake       CONTRIBUTORS.md  docker      include   Makefile    Makefile.config~  models                   scripts

rajathmb@rajathmb-VirtualBox:~/caffe/caffe$ ldd caffe
ldd: ./caffe: No such file or directory

rajathmb@rajathmb-VirtualBox:~/caffe/caffe$ ldd /home/rajathmb/caffe/caffe/
ldd: /home/rajathmb/caffe/caffe/: not regular file

rajathmb@rajathmb-VirtualBox:~/caffe/caffe$

Przemek D

unread,
Jan 27, 2017, 7:05:03 AM1/27/17
to Caffe Users
My bad, you should be in caffe/build/tools, where the caffe binary is. Execute ldd caffe there and look for line containing libcudart.so.8.0

Isabel Amaya

unread,
Nov 16, 2018, 3:54:31 AM11/16/18
to Caffe Users
@Przemek D 

What more? I have done ldd caffe

Thanks
Reply all
Reply to author
Forward
0 new messages