how to get CUDA syntax highlighting in Nsight VSCode extension when when cuda toolkit installed by Conda?

29 views Asked by At

I'm using Fedora 39 and installed cudatoolkit using conda install in a conda env (not base). When inside the conda env, I can do nvcc foo.cu && ./a.out and it works fine. (when I do which nvcc, it says ~/.conda/envs/foo-conda-env/bin/nvcc).

However, when editing cu source files in VSCode using the C/C++ extension and NSight plugin the intellisense syntax highlighting appears to be ordinary C++, not Cuda: see screenshot.enter image description here

In particular, notice __global__ is underlined. Of course there's also no autocomplete: when I type cudaDevi, it doesn't give me a menu with cudaDeviceSynchronize as one of the elements.

This is not surprising: I'm guessing if I had installed this to /usr/bin using nvidia's repo, so that the bin and libs and headers were all automatically in path, then the syntax highlighting would have worked fine. But if so, how do I tell the Nsight extension where to look for nvcc and the header files or whatever so that it can properly syntax highlight? I tried looking in user settings (UI) in VScode and there's absolutely nothing about NSight.

1

There are 1 answers

0
xdavidliu On

I solved this to my satisfaction by going from the tab with my .cu file in VScode and doing "Select IntelliSense Configuration". Then giving it the path to my nvcc binary, which in my case was /home/employee/.conda/envs/foo-conda-env/bin/nvcc.

After that, both the syntax highlighting for __global__ and the autocomplete were working perfectly.

enter image description here