VS Code & cuda code: compilerArgs of c_cpp_properties.json can break code error detection

I had problems working on cu files under VS Code. The __device__ keyword broke everything ( identifier "__device__ " is undefinedand expected a ';'). A perfectly compiling and working code showed hundreds of errors.

It took me hours of debugging it but I found the problem. The problem lies in the unexpected handling of the compilerArgs part of the c_cpp_properties.json file.

“compilerPath”: “/usr/local/cuda-12/bin/nvcc”,
“compilerArgs”: [
“-ccbin /usr/lib64/ccache/clang++”
leads to
Invoking nvcc with command line: /usr/local/cuda-12/bin/nvcc -allow-unsupported-compiler ‘-ccbin /usr/lib64/ccache/clang++’ […]
Unable to find host compile command in output of nvcc.
Please note the ’ ’ around the ccbin argument. VS code can not execute this broken command which results into chaos for the code analyser.

If I change it to “-ccbin=/usr/lib64/ccache/clang++” then I get
Invoking nvcc with command line: /usr/local/cuda-12/bin/nvcc -allow-unsupported-compiler -ccbin=/usr/lib64/ccache/clang++ […]
which works.

I thought that this is an error in vscode-cpptools. However they ( c_cpp_properties.json & compilerArgs : ' ' are automatically added to command line interpretation · Issue #10334 · microsoft/vscode-cpptools · GitHub ) say this is the expected behavior.

Can we please add information about that a working nvcc is mandatory by VS code for code writing too (and not just for debugging and compiling)? And how to set up the c_cpp_properties.json correctly for it. (E.g. I can not use a launch configuration because I am working on PyBind11 extensions)


Invoking nvcc with command line: /usr/local/cuda-12/bin/nvcc -allow-unsupported-compiler ‘-ccbin /usr/lib64/ccache/clang++’ /home/davrot/.vscode-server/data/User/workspaceStorage/504c0727523b326e8247a03ffadc5eae/ms-vscode.cpptools/nvcc_temp/temp.cu -c -x cu -odir /home/davrot/.vscode-server/data/User/workspaceStorage/504c0727523b326e8247a03ffadc5eae/ms-vscode.cpptools/nvcc_temp -keep -keep-dir /home/davrot/.vscode-server/data/User/workspaceStorage/504c0727523b326e8247a03ffadc5eae/ms-vscode.cpptools/nvcc_temp -v
Unable to find host compile command in output of nvcc.

  • OS and Version:
    Fedora 37
  • VS Code Version:
    Version: 1.74.2
    Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
    Date: 2022-12-20T10:27:19.253Z
    Electron: 19.1.8
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    OS: Linux x64 6.0.8-300.fc37.x86_64
    Sandboxed: No
  • C/C++ Extension Version:


nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Mon_Oct_24_19:12:58_PDT_2022
Cuda compilation tools, release 12.0, V12.0.76
Build cuda_12.0.r12.0/compiler.31968024_0

Thanks for reporting and the detailed information. I will file a bug to get this updated!