How can I avoid this error when creating a MEX file? "Error: Link of 'mexGPUexample.mex64' failed."

2 ビュー (過去 30 日間)
Hi all,
I am trying to compile the "mexGPUexample.cu" code according to the directions here: http://www.mathworks.com/help/distcomp/run-mex-functions-containing-cuda-code.html
I've followed the steps (changed environment variables, etc.) but when try to compile, I get the following:
>> mex mexGPUexample.cu
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'mexGPUexample.mexw64' failed.
Unable to complete successfully.
Is there a problem with space characters in a path name somewhere? I'm running 64-bit Windows 7 with MATLAB R2013b and CUDA 5.5 with the MS Visual Studio 2012 Pro C compiler.
Any help is appreciated! Here is the verbose output:
>> mex -v mexGPUexample.cu
***************************************************************************
Warning: 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, see:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
****************************************************************************
-> Default options filename found in C:\Users\e293911\Documents\MATLAB\Misc
----------------------------------------------------------------
-> Options file = C:\Users\e293911\Documents\MATLAB\Misc\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2013b
-> COMPILER = nvcc
-> Compiler flags:
COMPFLAGS = -gencode=arch=compute_13,code=sm_13 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=\"sm_30,compute_30\" -c --compiler-options=/GR,/W3,/EHs,/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE,/nologo,/MD
OPTIMFLAGS = --compiler-options=/O2,/Oy-,/DNDEBUG
DEBUGFLAGS = --compiler-options=/Z7
arguments =
Name switch =
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\ASP_2_~1\AppData\Local\Temp\mex_KtFoIb\templib.x" /MAP:"mexGPUexample.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"mexGPUexample.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"mexGPUexample.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> nvcc -gencode=arch=compute_13,code=sm_13 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=\"sm_30,compute_30\" -c --compiler-options=/GR,/W3,/EHs,/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE,/nologo,/MD -I"C:\Program Files\MATLAB\R2013b\extern\include" -I"C:\Program Files\MATLAB\R2013b\simulink\include" --compiler-options=/O2,/Oy-,/DNDEBUG -DMX_COMPAT_32 mexGPUexample.cu
Contents of C:\Users\ASP_2_~1\AppData\Local\Temp\mex_KtFoIb\mex_tmp.rsp:
mexGPUexample.obj
--> link /out:"mexGPUexample.mexw64" /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\ASP_2_~1\AppData\Local\Temp\mex_KtFoIb\templib.x" /MAP:"mexGPUexample.mexw64.map" @C:\Users\ASP_2_~1\AppData\Local\Temp\mex_KtFoIb\mex_tmp.rsp
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'mexGPUexample.mexw64' failed.
Unable to complete successfully.
  7 件のコメント
Edward
Edward 2013 年 12 月 30 日
Thanks - I am trying this. The LINKFLAGS line reads:
set LINKFLAGS= /dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map"
I changed the beginning of that line to:
set LINKFLAGS= -v /dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib
I'm still getting the same non-descript error message as before. Did I put the "-v" in the right place?
Thanks for the help so far!
Walter Roberson
Walter Roberson 2013 年 12 月 30 日
It appears that it should have been /VERBOSE
My guess is that it is not going to help.
I wonder if maybe the wrong LINK program is being used, but I do not really know how to check that in MS Windows.

サインインしてコメントする。

採用された回答

James Lebak
James Lebak 2014 年 1 月 3 日
Hi Edward,
You stated you were using CUDA 5.5 and VS 2012. When you build MEX files for the GPU, you must use the same version of the CUDA toolkit that was used to build the MATLAB GPU support. In the case of R2013b, that means CUDA 5.0. You can find out which CUDA toolkit version was used to build MATLAB from the gpuDevice command:
>> d=gpuDevice;d.ToolkitVersion
ans =
5
In addition, the MEX files that ship with R2013b are written for VS2010, as VS2012 was not officially supported by the CUDA 5.0 toolkit. If you have access to CUDA 5.0 and VS 2010 I would recommend trying that tool chain. If you are on maintenance and have access to the R2014a prerelease, you could also try compiling the code with that version of MATLAB, as it is written for CUDA 5.5.
  2 件のコメント
Edward
Edward 2014 年 1 月 6 日
This is discouraging news. When I found out that NVIDIA's Nsight profiler needed a professional version of Visual Studio, I bought VS2012 and then upgraded from CUDA 5.0 to 5.5... only to find out now that CUDA 5.5 isn't compatible with (also newly installed) MATLAB R2013b.
I guess I'll be sticking to CUDAKernel objects until I can upgrade to MATLAB R2014a.
Thanks for the insight!
Joss Knight
Joss Knight 2014 年 1 月 14 日
You can easily maintain both versions of CUDA for your purposes, you just need to manage your CUDA_PATH environment variable. Similarly, you wouldn't have any trouble installing VS2010 and VS2012 alongside each other, if you couldn't get VS2012 to play ball with CUDA 5.0.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by