Cuda_error_invalid_context

Hi, I’m using nsight compute to profile a python file with ncu --mode=launch python -u main.py, but I got
CUDA_ERROR_INVALID_CONTEXT in nsight compute GUI:
image
What can I do to solve this problem?
Any help would be so appreciated.

Hi, @hyaloids

Sorry for the issue you met.

Are you launching the script from ncu cli and attach from GUI ?
Can you just try ‘ncu python -u main.py’ directly in CLI ?

Which Nsight Compute version do you use ?
Is it possible to share us the main.py for repro ?

Hi,

  1. Yes, I’m doing a launch from ncu cli and attach from GUI.
  2. It shows that I don't have permission to access NVIDIA GPU Performance Counters on the target device 0. But I just tried to profile basic metrics, and users without permission can access these basic metrics I think.
  3. The NCU version I’m using is 2023.1.1.0
  4. I just simplified the command, it’s a big project, if you want to reproduce it, here’s the link https://github.com/HPMLL/DTC-SpMM_ASPLOS24, and I’m using H100 to reproduce the cusparse part, the working directory is ~/DTC-SpMM-ASPLOS24/scripts/cusparse

Thanks a lot!

Hi, @hyaloids

You need firstly resolve the permission issue to enable profile. Details please refer NVIDIA Development Tools Solutions - | NVIDIA Developer

You can simply add “sudo” in the command line to see the result.