Library not loaded: @rpath/libcudart.6.0.dylib

Hi everyone, I’m just starting to learn CUDA with MATLAB and this example program I found in a book (appears) to compile correctly after entering:

!nvcc -c AddVectors.cu -Xcompiler -fPIC -I /Applications/MATLAB_R2013a.app/extern/include/

mex AddVectorsCuda.cpp AddVectors.o -lcudart -lcufft -L /usr/local/cuda/lib

However when I try and actually run the program I get the message:

Invalid MEX-file ‘/blah…/AddVectorsCuda.mexmaci64’:
dlopen(/blah…/AddVectorsCuda.mexmaci64, 6): Library not
loaded: @rpath/libcudart.6.0.dylib
Referenced from: /blah…/AddVectorsCuda.mexmaci64
Reason: image not found

I’ve got

DYLD_LIBRARY_PATH=/usr/local/cuda/lib:/Developer/NVIDIA/CUDA-6.0/lib: and PATH=/Library/Frameworks/Python.framework/Versions/3.3/bin:/usr/local/cuda/bin:/Developer/NVIDIA/CUDA-6.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin

all set up in .bash_profile, and “libcudart.6.0.dylib” definitely exists in the expected location, but is MATLAB still not knowing where to look for certain libraries?

Hi

Have you solved your problem?

I have exactly the same problems despite that I have set DYLD_LIBRARY_PATH, LD_LIBRARY_PATH and PATH in Matlab.

I haven’t found a solution yet…

If you started MATLAB from an icon/shorcut (-nodesktop mode) it tends to disregard any variables in .bash_profile or similar. I’ve seen that behavior in Unix/Linux. See if doing this helps:

[url]MATLAB not seeing nvcc - CUDA Setup and Installation - NVIDIA Developer Forums
Not sure if BASH_ENV is the correct variable for MacOS, though, so you might just have to do a setenv for each of the 2 variables you referenced.

Edit: seems that was your same thread, actually. I thought you had figured that out?

Try this nifty script

function compile(fname)
clear mex
%CUDA='/usr/local/cuda-5.5/'
CUDA='/usr/local/cuda-6.0/'
C1FLAGS=[' -I' CUDA '/include -I./']
LDFLAGS=[' -L' CUDA '/lib64 -L./']
LKFLAGS=['-rpath=' CUDA '/lib64 -rpath=./']
str = ['mex ', fname, C1FLAGS, LDFLAGS, ' LINKFLAGS="\$LINKFLAGS ' LKFLAGS '" -lcusparse -lcublas -lcudart']
eval(str);
end