0

So I got this error when running a python script that wraps around caffe. I was like "oh right, go fix .bashrc so it knows what you're trying to do". A la

export PYTHONPATH=/home/ubuntu/caffe/python

it still doesn't work. I tried the test scripts that come with caffe so it's fine and works properly but just not through python importing. Nothing went wrong during compiling caffe and my Makefile.config directs to the library correctly by default unless I'm missing something. I can paste that as well (this is ubuntu 14.04).

# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# 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

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

Thanks in advance for helpin' out. This is on an AWS instance so I'm paying until I can figure this out unfortunately.

Dylan Moore
  • 443
  • 4
  • 14
  • Did you source the .bashrc? See if it print when you type "echo $PYTHONPATH". – Bruce Pucci Jun 28 '16 at 18:40
  • What are the contents of /home/ubuntu/caffe/python? – cdarke Jun 28 '16 at 18:42
  • @BrucePucci the correct location in the original "home/ubuntu/caffe/python" – Dylan Moore Jun 28 '16 at 19:08
  • @cdarke "caffe classify.py CMakeLists.txt detect.py draw_net.py requirements.txt" – Dylan Moore Jun 28 '16 at 19:08
  • I don't see a `caffe.py` or a shared library of that name, unless `caffe` a directory? Are you sure that this is the right directory, and that `import caffe` is correct - always assuming that is what you are doing, since you don't show that. – cdarke Jun 28 '16 at 22:01
  • import caffe is indeed what I'm doing in a script elsewhere, which is also imported (but working fine otherwise) and you're correct, "caffe" is a directory. All documentation suggests this is where it should be reading from but I'll doublecheck. Just checked and it also has __init__.py in the folder, so this is indeed a package that should be used but isn't working. – Dylan Moore Jun 28 '16 at 23:02
  • `>>> import sys >>> sys.path.append('/home/ubuntu/caffe/python') >>> import caffe Traceback (most recent call last): File "", line 1, in File "/home/ubuntu/caffe/python/caffe/__init__.py", line 1, in from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver File "/home/ubuntu/caffe/python/caffe/pycaffe.py", line 13, in from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory` – Dylan Moore Jun 28 '16 at 23:14
  • and so I did this "printenv LD_LIBRARY_PATH" and got ":/usr/local/cuda-7.5/lib64" – Dylan Moore Jun 29 '16 at 16:14
  • I ended up solving it by modifying some code to fit my situation. Thanks for the help. – Dylan Moore Jun 29 '16 at 20:16

0 Answers0