Unrecognized function or variable 'nvcc'. with Matlab R2022a

I am running Matlab R2022a with CUDA 11.2 on Windows (Visual Studio Community 2019). I have a add_kernel.cu file in my folder but fail to compile it:
nvcc -ptx add_kernel.cu
Unrecognized function or variable 'nvcc'.
Matlab seems to recognize my CUDA version:
system('nvcc --version')
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:15:10_Pacific_Standard_Time_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0
ans =
0
I have looked around and people suggested to explicitly add the pathes of the ncc file and the VS execution which I already tried:
addpath(genpath('C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64'))
addpath(genpath('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin'))
I think it is irrelavent but Matlab also finds my GPU:
gpuDevice
CUDADevice with properties:
Name: 'NVIDIA GeForce RTX 3060'
Index: 1
ComputeCapability: '8.6'
SupportsDouble: 1
DriverVersion: 11.7000
ToolkitVersion: 11.2000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.2884e+10
AvailableMemory: 1.1646e+10
MultiprocessorCount: 28
ClockRateKHz: 1777000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
I would be glad about any suggestions.

 採用された回答

Raymond Norris
Raymond Norris 2022 年 9 月 1 日

0 投票

nvcc is a NVIDIA compiler, not a MATLAB function. I suspect what you want is mexcuda.

7 件のコメント

Felix Wellschmied
Felix Wellschmied 2022 年 9 月 1 日
Thank you very much. I falsely read from the following article that nvcc is the Matlab comand and not mexcuda:
My fault. Thank you for your quick reply!
Ayaz ul Hassan Khan
Ayaz ul Hassan Khan 2024 年 2 月 29 日
@Raymond Norris, I am getting the error in using mexcuda instead. Can you please help?
>> mexcuda -ptx myKernel.cu
Error using mex
Supported compiler not detected. For options, visit https://www.mathworks.com/support/compilers.
Error in mexcuda (line 185)
[varargout{1:nargout}] = mex(mexArguments{:});
Raymond Norris
Raymond Norris 2024 年 2 月 29 日
Hi @Ayaz ul Hassan Khan this implies that you don't have mex setup properly. I would suggest running
mex -setup
and configuring MEX to your C compiler.
Felix Wellschmied
Felix Wellschmied 2024 年 3 月 1 日
Just as a note, for me, the compiler is in a different directlory than in my original post:
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64"
It obviously depends on the version of your VS.
Ayaz ul Hassan Khan
Ayaz ul Hassan Khan 2024 年 3 月 21 日
mex is already setup at my end but still getting the following error:
>> mexcuda -ptx myKernel.cu
Error using mex
Supported compiler not detected. For options, visit https://www.mathworks.com/support/compilers.
Error in mexcuda (line 185)
[varargout{1:nargout}] = mex(mexArguments{:});
>> mex -setup
MEX configured to use 'Microsoft Visual C++ 2022 (C)' for C language compilation.
To choose a different C compiler, select one from the following:
MinGW64 Compiler (C) mex -setup:'C:\Program Files\MATLAB\R2023b\bin\win64\mexopts\mingw64.xml' C
Microsoft Visual C++ 2022 (C) mex -setup:C:\Users\ayazh\AppData\Roaming\MathWorks\MATLAB\R2023b\mex_C_win64.xml C
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
MEX configured to use 'Microsoft Visual C++ 2022' for C++ language compilation.
To choose a different C++ compiler, select one from the following:
MinGW64 Compiler (C++) mex -setup:'C:\Program Files\MATLAB\R2023b\bin\win64\mexopts\mingw64_g++.xml' C++
Microsoft Visual C++ 2022 mex -setup:C:\Users\ayazh\AppData\Roaming\MathWorks\MATLAB\R2023b\mex_C++_win64.xml C++
>>
Raymond Norris
Raymond Norris 2024 年 3 月 21 日
@Ayaz ul Hassan Khan please contact MathWorks Technical Support. They'll get this quickly resolved for you.
Ayaz ul Hassan
Ayaz ul Hassan 2024 年 3 月 22 日
Thanks, contacted support. Hope to get quick resolution.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

製品

リリース

R2022a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by