>> mex -setupMEX 配置为使用 'Microsoft Visual C++ 2015 Professional (C)' 以进行 C 语言编译。警告: MATLAB C 和 Fortran API 已更改,现可支持包含 2^32-1 个以上元素的 MATLAB 变量。不久以后,您需要更新代码以利用新的 API。您可以在以下网址找到相关详细信息:http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html。要选择不同的语言,请从以下选项中选择一种命令:mex -setup C++mex -setup FORTRAN
matlabroot/toolbox/distcomp/gpu/extern/src/mex/
目录下,比如我的matlab安装在 C:\Program Files\MATLAB\R2016a\ 中,这个文件就在 C:\Program Files\MATLAB\R2016a\toolbox\distcomp\gpu\extern\src\mex。
>> mexcuda mexGPUExample.cu警告: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported compiler.> In mexcuda (line 89)错误使用 mex未找到支持的编译器或 SDK。有关选项,请访问 http://www.mathworks.com/support/compilers/R2016a/win64.html。出错 mexcuda (line 157)[varargout{1:nargout}] = mex(mexArguments{:});
This Answer provides a workaround to force MATLAB to use CUDA 8.0 and Visual Studio 14:
This is how to compile (*mexcuda*) with Visual Studio 2015 and Cuda 8.0 :
- Go to: "\toolbox\distcomp\gpu\extern\src\mex\win64"
- Copy files and rename 2013 to 2015: { "nvcc_msvcpp2013.xml" , "nvcc_msvcpp2013_dynamic.xml"}
- Replace inside those files "7.5" to "8.0" and "12" to "14".
- Done.
>> mexcuda mexGPUExample.cu使用 'NVIDIA CUDA Compiler' 编译。错误使用 mexnvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a futurerelease (Use -Wno-deprecated-gpu-targets to suppress warning).mexGPUExample.cuD:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/Bin/amd64/../../../VC/INCLUDE\crtdefs.h(10): fatal error C1083:无法打开包括文件: “corecrt.h”: No such file or directory出错 mexcuda (line 157)[varargout{1:nargout}] = mex(mexArguments{:});
>> mexcuda mexGPUExample.cu使用 'NVIDIA CUDA Compiler' 编译。c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h: warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(849): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失...c:\program files\nvidia gpu computing toolkit\cuda\v8.0\include\math_functions.h(7956): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失MEX 已成功完成。
x = ones(4,4,'gpuArray');y = mexGPUExample(x)
>> x = ones(4,4,'gpuArray');>> y = mexGPUExample(x)未定义函数或变量 'mexGPUExample'。
>> x = ones(4,4,'gpuArray');>> y = mexGPUExample(x)y = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1020




被折叠的 条评论
为什么被折叠?



