.cu file compilation error (while mex -setup works, mexcuda gives unsupported compiler error although nvcc compiler is installed in my PC)

4 views (last 30 days)
I'm trying to compile CUDA Mex file with .cu extension with MATLAB 2018b, CUDA Toolkit version 9.1 and Visual Studio 2015 Professional. The Graphics Processing Unit in my PC is GeForce GTX 1050. In Matlab, When I call the command gpuDevice, I have the output as follows
>> gpuDevice
ans =
CUDADevice with properties:
Name: 'GeForce GTX 1050'
Index: 1
ComputeCapability: '6.1'
SupportsDouble: 1
DriverVersion: 10
ToolkitVersion: 9.1000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 4.2950e+09
AvailableMemory: 3.4635e+09
MultiprocessorCount: 5
ClockRateKHz: 1493000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
If I tries compiling a default mexGPUExample.cu, it is showing
>> 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\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2017.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2012.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2015.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\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2017.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' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
Did not find installed compiler 'NVIDIA CUDA Compiler'.
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
I also tried
setenv('MW_NVCC_PATH','C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin')
Compiling failed.
In Matlab environment, I type the commands below it didn't work again
>> !nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:08:12_Central_Daylight_Time_2017
Cuda compilation tools, release 9.1, V9.1.85
How can I tackle this issue?
  1 Comment
Joss Knight
Joss Knight on 2 Feb 2019
It's hard to say because your currently selected host compiler is MSVC 2017, which you don't have. Use mex -setup to select Visual Studio 2015, then run in verbose mode again so we can see exactly what is failing. Or just type
mexcuda -f "C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2015.xml" -v mexGPUExample.cu
and show us what the output was again.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!