Note on NVIDIA Drivers InstallationΒΆ

When setting up the virtual machine, you may not have the CUDA drivers pre-installed. During the installation process, CUDA drivers and the toolkit are handled by the script. The installer will check if the CUDA drivers are working properly with:

nvidia-smi

If the command is not present or fails, you will be prompted to install the drivers through the script.

  • If you answer any of (y|Y|yes|YES), the script will do the following:

    # Retrieve your OS name and version
    . /etc/os-release
    OS_ID=$ID
    OS_VERSION_ID=$VERSION_ID
    ARCH=$(uname -m)
    
    # Retrieve your architecture
    case "$ARCH" in
    x86_64)
        ARCH_PATH="x86_64"
        ;;
    aarch64)
        ARCH_PATH="arm64"
        ;;
    esac
    
    # Build a URL from this information to retrieve the installation kit from the NVIDIA archive
    URL="https://developer.download.nvidia.com/compute/cuda/repos/${OS_ID}${OS_VERSION_ID}/${ARCH_PATH}/cuda-keyring_1.1-1_all.deb"
    
    # Add the NVIDIA CUDA keyring and repository
    wget $URL
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    sudo apt-get update
    sudo apt-get -y install cuda
    
  • If you have any doubts, please skip the CUDA installation by answering no to the prompt. Then follow the official tutorial provided by cloud.google.com. You will find three different guides:

    • Install GPU drivers on VMs using NVIDIA guides.

      • In particular, when clicking on NVIDIA CUDA Toolkit, you will be redirected to the archive page. To download the latest CUDA toolkit, they suggest a script very similar to the one above:

        wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
        sudo dpkg -i cuda-keyring_1.1-1_all.deb
        sudo apt-get update
        sudo apt-get -y install cuda-toolkit-12-8 # By choosing `cuda` instead of `cuda-toolkit-12-8`, both the toolkit and drivers are installed
        
    • Install GPU drivers on VMs using the installation script.

      • In practice, this script may not always work as expected. Following the NVIDIA instructions is generally more reliable, but requires a better understanding of the process.

    • Install GPU drivers on Secure Boot VMs

      • This was not my use case. I am unsure how Secure Boot VMs interact with Nix. Please open an issue if you encounter any problems or have relevant information.