Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX 10.11 linking issue: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and dyld: Library not loaded: @rpath/libcudart.7.5.dylib #3628

Closed
lettergram opened this issue Feb 3, 2016 · 14 comments
Labels

Comments

@lettergram
Copy link

I am receiving the following errors for both make runtest and ./examples/mnist/create_mnist.sh. Make all and make test ran fine.

$ make runtest
.build_release/tools/caffe
dyld: Library not loaded: @rpath/libcudart.7.5.dylib
  Referenced from: /Users/kht516/Development/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5
$ ./examples/mnist/create_mnist.sh
Creating lmdb...
dyld: Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /Users/username/Development/caffe/build/examples/mnist/convert_mnist_data.bin
  Reason: image not found

I am currently running:
OX: 10.11.2
Macbook Pro 15 inch Retna Mid-2015
No GPU - Graphics Intel Iris Pro 1536 Mb

I have looked at Here to try and fix the problem, to no avail.

I have installed openBLAS and followed all the instructions.

@yutkin
Copy link

yutkin commented Feb 6, 2016

After make test in $CAFFE_ROOT:
cp -a .build_release/lib/. /usr/local/lib/

@gyurisc
Copy link

gyurisc commented Feb 6, 2016

@yutkin the cp command helped me. Now, I am able to runtest.

@datomnurdin
Copy link

Thank you!! solved!!

@lettergram
Copy link
Author

Because I am not using the GPU, I don't have libcudart, which means when I run:

$ make runtest

I receive the following:

dyld: Library not loaded: @rpath/libcudart.7.5.dylib
  Referenced from: /Users/kht516/Development/ml/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5

@yutkin
Copy link

yutkin commented Feb 9, 2016

@lettergram Please, show your Makefile.config.

@jason718
Copy link

@yutkin THX!!!!!!!!

@lettergram
Copy link
Author

@yutkin Here is my Makefile.config

## Refer to http://caffe.berkeleyvision.org/installation.html                                                           
# Contributions simplifying and improving our build system are welcome!                                                 

# 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                                                                                                   

# To customize your choice of compiler, uncomment and set the following.                                                
# N.B. the default for Linux is g++ and the default for OSX is clang++                                                  
# CUSTOM_CXX := g++                                                                                                     

# CUDA directory contains bin/ and lib/ directories that we need.                                                       
# CUDA_DIR := /usr/local/cuda                                                                                           
# On Ubuntu 14.04, if cuda tools are installed via                                                                      
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:                                                     
# CUDA_DIR := /usr                                                                                                      

# CUDA architecture setting: going with all of them.                                                                    
# For CUDA < 6.0, comment the *_50 lines for compatibility.                                                             
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
                -gencode arch=compute_20,code=sm_21 \
                -gencode arch=compute_30,code=sm_30 \
                -gencode arch=compute_35,code=sm_35 \
                -gencode arch=compute_50,code=sm_50 \
                -gencode arch=compute_50,code=compute_50

# 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                                                                       

# 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 depe\
ndencies                                                                                                                
# 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                                                                                                   

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 ?= @

@lettergram
Copy link
Author

I actually have the same problem with another Mac I have:

OS X El Capitan Version 10.11.3
MacBook Pro (Retina, 15-inch, Mid 2014)
Processor 2.5 GHz Intel Core i7
Memory 16 GB 1600 MHz DDR3
Graphics: NVIDIA GeForce GT 750M 2048 MB

$ make Install

Success

$ make test

Success

$ make runtest

Failure

Receiving the following:

make runtest
.build_release/tools/caffe
dyld: Library not loaded: @rpath/libcudart.7.5.dylib
  Referenced from: /Users/kht516/Development/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5

The issue seems to be the same as #2320.

However, I do not have the option to disable csrutil.

Is there some other solution I could try?

@lettergram lettergram changed the title make runtest error: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 make runtest error: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and dyld: Library not loaded: @rpath/libcudart.7.5.dylib OS X Feb 11, 2016
@lettergram lettergram changed the title make runtest error: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and dyld: Library not loaded: @rpath/libcudart.7.5.dylib OS X make runtest error: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and @rpath/libcudart.7.5.dylib OS X 10.11 Feb 11, 2016
@aghagol
Copy link

aghagol commented Feb 15, 2016

Did you try (locating and) copying those libraries (libcudart.7.5.dylib) to /usr/local/lib/ as @yutkin suggested? Just wondering.

@lettergram
Copy link
Author

@aghagol I did, it did not appear to work.

@rollingstone
Copy link

I had the similar problem. The following steps solved the issue. (caffe is installed in ~/caffe)
I have anaconda python distribution.


brew uninstall python
sudo mv  /System/Library/Frameworks/Python.framework /System/Library/Frameworks/Python.framework.bak
(just to make sure only anaconda python is used)

make all -j8
make test -j8

cp -a ~/caffe/.build_release/lib/. /usr/local/lib/

Modified ~/.profile (or in ~/.bashrc)

export PYTHONPATH=~/caffe/python:$PYTHONPATH

unset DYLD_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH=~/anaconda/lib:/usr/local/lib

then ....
make runtest 

hope it helps

@givenjazz
Copy link

@rollingstone THX.
I had the similar problem, too.

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/cuda/lib

@shelhamer
Copy link
Member

The libcaffe.so linking issue as shown by

$ ./examples/mnist/create_mnist.sh
Creating lmdb...
dyld: Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /Users/username/Development/caffe/build/examples/mnist/convert_mnist_data.bin
  Reason: image not found

is fixed in #3696.

The CUDA linking error is fixed in #3695. Note however that if you do not have a GPU you should build in CPU-only mode to save yourself the headache of installing CUDA at all.

@shelhamer shelhamer changed the title make runtest error: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and @rpath/libcudart.7.5.dylib OS X 10.11 OSX 10.11 linking issue: dyld: Library not loaded: libcaffe.so.1.0.0-rc3 and dyld: Library not loaded: @rpath/libcudart.7.5.dylib Feb 21, 2016
@victorv
Copy link

victorv commented Feb 23, 2017

We ran into this problem as we build mutiple targets from the same source (cpu, cuda, opencl, alt) and each goes into a separate BUILD_DIR as specified in Makefile.config. Unfortunately, Makefile assumes all the builds go into a "build" directory. Here is a patch to Makefile -

diff --git a/Makefile b/Makefile
index f8652a5..270cb7e 100644
--- a/Makefile
+++ b/Makefile
@@ -298,7 +298,7 @@ ifeq ($(OSX), 1)
LIBRARIES += boost_thread-mt
# we need to explicitly ask for the rpath to be obeyed
ORIGIN := @loader_path

  •   VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
    
  •   VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../$(BUILD_DIR)/lib
    

else
ORIGIN := $$ORIGIN
endif
@@ -515,7 +515,7 @@ $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@ $&lt;
$(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC)
-o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \

  •           -Wl,-rpath,$(ORIGIN)/../../build/lib
    
  •           -Wl,-rpath,$(ORIGIN)/../../$(BUILD_DIR)/lib
    

mat$(PROJECT): mat

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

No branches or pull requests

10 participants