cudagoogle-colaboratorynsight

Trouble using Nsight Compute on Google Colab: 'command not found' error with ncu and installation script error with Nsight Compute


I am trying to use ncu on Colab, however when I type

ncu
/bin/bash: ncu: command not found

A few days ago this command was working fine, I am unsure if I am making some mistakes in the code or if it is a problem with colab.

And I cannot install Nsight because if I run this:

!chmod +x  /content/drive/MyDrive/ncu/nsight-compute-Linux-2023.1.0.16-32451174.run
!/content/drive/MyDrive/ncu/nsight-compute-Linux-2023.1.0.16-32451174.run  --confirm

It shows after the license it presents this error

The program './install-Linux.pl' returned an error code (1)

I cannot use nvprof because of this error (nvprof is no longer supported on new architecture)

======== Warning: Skipping profiling on device 0 since profiling is not supported on devices with compute capability 7.5 and higher.
                  Use NVIDIA Nsight Compute for GPU profiling and NVIDIA Nsight Systems for GPU tracing and CPU sampling.
                  Refer https://developer.nvidia.com/tools-overview for more details.

Solution

  • Here are instructions to install CUDA Toolkit 12.1 on Google Colab, which includes Nsight Compute:

    1. Download and install CUDA 12.1 from NVIDIA's installer
    ! set -x \
    && cd $(mktemp -d) \
    && wget https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run \
    && sudo sh cuda_12.1.0_530.30.02_linux.run --silent --toolkit \
    && rm cuda_12.1.0_530.30.02_linux.run
    
    1. Add CUDA binaries folder to PATH
    import os
    os.environ['PATH'] = os.environ['PATH'] + ':/usr/local/cuda/bin/'
    
    1. Run Nsight Compute!
    ! ncu --version
    

    Feel free to clone my existing Google Colab notebook here!