필터 지우기
필터 지우기

nvcc fatal : Value 'c++17' is not defined for option 'std'

조회 수: 67 (최근 30일)
Vyacheslav Samokhvalov
Vyacheslav Samokhvalov 2021년 6월 23일
댓글: Joss Knight 2021년 6월 24일
Hello,
I'm would like to use some C++17 features in my library. The library is header only, and compiles with MSVC 15.19 v14.16 toolset and CUDA 11.3 that are installed on my machine. I wrap this library in a mex function which acts as an interface for inputs and outputs from and to Matlab, but having trouble compiling it.
I use the following command to compile:
mexcuda -v -R2018a '-LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\lib\x64' -lcublas ...
NVCC_FLAGS='-std=c++17 -Xcompiler=/std:c++17 --default-stream legacy'...
.\path\to\mex\file.cu
and get:
Error using mex
nvcc fatal : Value 'c++17' is not defined for option 'std'
In the nvcc_msvcpp2017.xml build configuration file I noticed that CUDA 10.1 is referenced. This version indeed does not support C++17 standard, but I find it bizzare that anything would compile at all seing as I do not have CUDA 10.1 installed on my system (unless it shipped with Matlab). I tried creating a custom .xml file to correct the versioning but that did not solve the issue, my guess though is that I need to adjust some environment variable, but I have no clue which one.
Thank for your help!
  댓글 수: 1
Joss Knight
Joss Knight 2021년 6월 24일
"I find it bizzare that anything would compile at all seing as I do not have CUDA 10.1 installed on my system (unless it shipped with Matlab)"
It is! From the doc:

댓글을 달려면 로그인하십시오.

답변 (1개)

Linda Koletsou Soulti
Linda Koletsou Soulti 2021년 6월 23일
Hello Vyacheslav,
In order to specify the location of NVCC on your system for MEXCUDA to use, you should execute the following command:
setenv('MW_NVCC_PATH','/path/to/your/nvcc');
The version of the CUDA Toolkit that you can safely use, is the one supported by your MATLAB release. You can find more information on that along with the compatible version of the CUDA Toolkit for your release on the following link:
Cheers,
Linda
  댓글 수: 2
Vyacheslav Samokhvalov
Vyacheslav Samokhvalov 2021년 6월 24일
편집: Vyacheslav Samokhvalov 2021년 6월 24일
It seems that setting
setenv('MW_NVCC_PATH','/path/to/your/nvcc');
makes no difference. It looks like MATLAB Parallel Toolbox ships CUDA 10.1. Looking at lines 220-223 in nvcc_msvcpp2017.xml mex configuration file, the PATH variable concatenates
PATH="$MATLABROOT\sys\cuda\$ARCH\cuda\nvvm\bin;$MATLABROOT\sys\cuda\$ARCH\cuda\bin"
Idem for LIB with
LIB="$MATLABROOT\sys\cuda\$ARCH\cuda\lib\x64"
This means that even if I have a newer version of CUDA installed on my machine, despite the setting in MW_NVCC_PATH, CUDA 10.1 shipped with MATLAB is used to compile the code. The argument -LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\lib\x64 to link CUBLAS from a newer version of CUDA produced no errors, because CUBLAS from $MATLABROOT\sys\cuda\$ARCH\cuda\lib\x64 was linked to instead.
Linda Koletsou Soulti
Linda Koletsou Soulti 2021년 6월 24일
Hello Vyacheslav,
We do not support using a different version of the CUDA Toolkit than the one supported by your version of MATLAB. It seems that the version of MATLAB you use supports the CUDA Toolkit version 10.1.
You can find more information about the compatible version of the CUDA Toolkit for each release on the following link:
Cheers,
Linda

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU CUDA and MEX Programming에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by