Set Environment Variables in launch.json When Using Nsight Visual Studio Code Edition

I am developing a CUDA application in vs code and would like to debug it with cuda-gdb, which is integrated in nsight visual studio code edition as an IDE. One requirement in using nsight visual studio code edition to debug my application is that environment variables need to be set before starting my application, e.g., “export CUDA_DEVICE_ORDER=PCI_BUS_ID” and “export CUDA_VISIBLE_DEVICES=0,1,2,3”, as these variables are used by my application. When using vscode-integrated gdb (rather than cuda-gdb), we can configure launch.json with the pair "console": "integratedTerminal" to notify the vs code session not to start a new terminal when debugging (Otherwise, the environment variables set would be lost). Is there a similar solution for nsight visual studio code edition to reserve environment variables?

1 Like

I also need a solution to this.

Please try the latest version, is has a new launch setting called envFile where you can specify a file that contains [var]=[value] lines to configure environment variables.