我使用的是Windows 10,这里是mex使用的编译器(正如你可以看到我使用Visual Studio C ++ 2015):
>> mex -setup c++
MEX configured to use 'Microsoft Visual C++ 2015 Professional' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different C++ compiler, select one from the following:
MinGW64 Compiler (C++) mex -setup:'C:\Program Files\MATLAB_R2016b\bin\win64\mexopts\mingw64_g++.xml' C++
Microsoft Visual C++ 2015 Professional mex -setup:C:\Users\LENOVO\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C++_win64.xml C++
这是使用gpuDevice的结果:
>> gpuDevice
ans =
CUDADevice with properties:
Name: 'Quadro M1000M'
Index: 1
ComputeCapability: '5.0'
SupportsDouble: 1
DriverVersion: 8
ToolkitVersion: 7.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1475e+09
AvailableMemory: 1.6919e+09
MultiprocessorCount: 4
ClockRateKHz: 1071500
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
在Windows命令提示符下,检查nvcc时的结果:
C:\Users\LENOVO>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Mon_Jan__9_17:32:33_CST_2017
Cuda compilation tools, release 8.0, V8.0.60
然而,似乎有一些警告:
C:\Users\LENOVO>nvcc
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc fatal : No input files specified; use option --help for more information
无论如何,当我尝试使用mexcuda编译mexGPUExample.cu时,出现错误:
>> mexcuda -v mexGPUExample.cu
Warning: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported
compiler.
> In mexcuda (line 89)
Trying MEX options 'C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2012.xml'...FAILED
Warning: No supported host compiler found, or other problem with the environment.
Continuing with selected compiler to provide detailed diagnosis.
> In mexcuda (line 130)
mex -largeArrayDims -f C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml NVCC_FLAGS="" -v mexGPUExample.cu
Verbose mode is on.
... Looking for compiler 'NVIDIA CUDA Compiler' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
Did not find installed compiler 'NVIDIA CUDA Compiler'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2016b/win64.html.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
但是我已经安装了C ++编译器支持的Visual C ++ 2015编译器(根据:https://www.mathworks.com/matlabcentral/answers/270635-mexcuda-error-on-windows-10-matlab-2015-b)。我很困惑:( 请帮助我,非常感谢
答案 0 :(得分:1)
MATLAB R2016b需要CUDA 7.5,它不支持Visual Studio 2015.所以它首先要做的是检查你可以使用的Visual Studio版本,这是你没有的。
此Matlab答案提供了一种强制MATLAB使用CUDA 8.0和Visual Studio 14的解决方法: