CUDA and Matlab on mac: mex command not working

3 visualizzazioni (ultimi 30 giorni)
Jack Zhang
Jack Zhang il 19 Set 2015
Modificato: Joss Knight il 13 Ott 2015
Hi,
I am interested to compile the program in here for GPU enabled computation on matlab. I have Matlab R2015a, Xcode7, and CUDA 7.0 already on OSX 10.11. However during the compiling, it complain about "mex" function.
mex -silent -largeArrayDims -outdir ../mex_executables -I../src -I/Developer/NVIDIA/CUDA-7.0/include get_radial_distribution_2D.cpp -L../src -lfftw3f -L../src -lfftw3 -lfftw3f_threads -lfftw3_threads
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html.
Error in MEX (line 31)
eval(textcommands);
Error in mex_radial_distribution_2D (line 3)
MEX('release', 'get_radial_distribution_2D.cpp', '../src');
Error in run (line 96)
evalin('caller', [script ';']);
Error in compile_mex_files (line 31)
run(['mex_files/', file{1}])
Thus, I tried to test the example file at
matlabroot/toolbox/distcomp/gpu/extern/src/mex/mexGPUExample.cu
>> mex -v mexGPUExample.cu
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... Looking for compiler 'nvcc' ...
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Executing command 'which nvcc' ...No.
... Looking for file '/Developer/NVIDIA/CUDA-6.5/bin/nvcc' ...No.
... Looking for file '/usr/local/cuda/bin/nvcc' ...Yes.
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('7.0').
... Executing command '
agreed=7.0
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('7.0').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' ...No.
... Executing command 'find /Applications/Xcode.app/Contents/Developer -name MacOSX10.9.sdk' ...No.
Did not find installed compiler 'nvcc'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html.
Is it caused by cuda 7.0 not supporting xcode 7.0 yet? Thanks a lot for your help!

Risposte (2)

Joss Knight
Joss Knight il 12 Ott 2015
Modificato: Joss Knight il 13 Ott 2015
I can see that this code on File Exchange brings with it its own copies of the CUDA MEX options files for each platform ('mex_files/mex_CUDA_maci64.xml'). They are odd. The Mac one and the Windows one 'support' CUDA 7.5, but that isn't supported in any released version of MATLAB - so these files must have been doctored by the authors, at great risk to their users. Plus presumably you have an older version because your verbose output indicates MEX is looking for CUDA 7.0, not 7.5.
However, this is a moot point, since this package is compiling with mex when it should now be using mexcuda, which takes care of finding the right options file for you. You need to change the calls to MEX in all the files starting 'mex_' to mexcuda. This won't exactly fix your problem because neither mex nor mexcuda support MacOSX SDK 10.11. This is because that SDK wasn't out when we finished MATLAB R2015b - plus CUDA's compiler doesn't support it. Forcing your code to use the 10.11 SDK could cause undefined behaviour.
So, my advice would be to use mexcuda, and to get an earlier version of XCode that comes with the 10.10 SDK.
Nevertheless, if you really want to hack the options file to allow support for SDK 10.11, then copy it from [matlabroot '/toolbox/distcomp/gpu/extern/src/mex/maci64/nvcc_maci64.xml'] to somewhere local, make the edits as explained in the other Answer, and force mexcuda to use your edited file using the -f option.
  2 Commenti
Walter Roberson
Walter Roberson il 13 Ott 2015
Which version introduced mexcuda? I thought it was 2015B? The user has 2015A
Joss Knight
Joss Knight il 13 Ott 2015
Modificato: Joss Knight il 13 Ott 2015
mexcuda came out in R2015b, yes.
Okay, well this is very confusing. The user, Jack, appears to be attempting to compile MEX code with an incompatible version of CUDA and an unsupported version of the MacOSX SDK using mex options written for a different version of MATLAB that have been doctored so that they are no longer valid...
Okay, so here's my advice.
1. Get an earlier copy of XCode that comes with the MacOSX 10.9 SDK (supported by MATLAB R2015a).
2. Download and install the CUDA 6.5 toolkit from NVIDIA's website (the one supported by MATLAB R2015a).
3. Following the instructions for compiling CUDA MEX in R2015a, replace the options files 'mex_CUDA_maci64.xml' in the 'mex_files' directory with the one from your MATLAB release (in matlabroot/toolbox/distcomp/gpu/extern/src/mex/maci64/clang').
4. If it is absolutely unacceptable to get a compatible version of XCode, make the edits suggested in the other Answer to your options file as appropriate, and take the risk.

Accedi per commentare.


Walter Roberson
Walter Roberson il 19 Set 2015
  3 Commenti
Walter Roberson
Walter Roberson il 19 Set 2015
Hmmm, the file exists in R2014a but I can prove it is not being paid attention to :(
Joss Knight
Joss Knight il 13 Ott 2015
mex by default will use a file in your local directory called 'mex_CUDA_<arch>.xml' for its options when compiling a .cu file, so it won't be using the clang_maci64.xml referred to. See my answer below.

Accedi per commentare.

Categorie

Scopri di più su MATLAB Compiler SDK in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by