Hi guys, I don’t think my nvcc is set up correctly. If I try and compile an example program I get the error:
$ nvcc -c AddVectors.cu
nvcc warning : The ‘compute_10’ and ‘sm_10’ architectures are deprecated, and may be removed in a future release.
AddVectors.cu:2:10: fatal error: ‘mex.h’ file not found #include “mex.h”
^
1 error generated.
I typed the program in exactly as it was in my book, so I’m thinking there’s something wrong with the path the compiler is using to search for mex.h? I’m running OS X 10.9 and have Xcode 5.1 beta 5 installed.
Any help would be greatly appreciated, thanks.
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?
MATLAB is incredibly picky and tends to ignore environment variables sometimes and re-defines then on startup. You might need to redefine the variables that point to the correct libraries within MATLAB. This issue is not necessarily unique to MEX files either, it happens when starting executables that depends on external libraries as well. I’ve seen this happen on Linux platforms more often than Windows, but doesn’t surprise me that it happened on a Mac.
global void addVectorsMask(float* A, float* B, float* C, int size)
{
int i = blockIdx.x;
if(i >= size)
return;
C[i] = A[i] +B[i];
}
Since this is the .cu file, we don’t need the “mex.h” file.
Actually we already corrected in our example codes (downloaded from the publisher’s website), but we didn’t delete it in our manuscript by mistake.