VK Cloud logo

Updating CUDA components

  1. Connect to the VM with the GPU.

  2. If needed for compatibility with CUDA after the update, the GPU driver.

  3. Check the version of the CUDA components.

    1. Determine the CUDA Toolkit version:

      /usr/local/cuda/bin/nvcc --version 2>/dev/null || /usr/local/cuda-*/bin/nvcc --version

      A No such file or directory error usually means CUDA Toolkit is not installed.

    2. Determine the version of CUDA Runtime, CUDA Libraries, and cuDNN:

      ldconfig -p | grep -E 'libcudart\.so|libcuda\.so|libcublas\.so|libcudnn\.so'
      • libcudart.so — CUDA Runtime.
      • libcublas.so — CUDA Libraries.
      • libcuda.so — the driver library. It should be listed if the driver is installed correctly. You can check whether the driver is installed or reinstall it in Installing the Linux GPU driver.
      • libcudnn.so — cuDNN.

      If a library is not listed, the corresponding component is not installed on the system.

    If a component is missing, choose one of the following scenarios.

    • Install the missing components in the required version, and then return to the update. Use this method if a clean install is not needed.
    • Reinstall all components completely. To do this, first remove all components completely, and then return to the installation. Use this method if you need to downgrade the version or perform a clean install.
  4. Determine how the CUDA components were installed:

    dpkg -l | grep -E 'cuda-|nvidia-cuda-toolkit'

    A CUDA component that is installed but not listed here means it is not linked to your package manager. Usually this means the component was installed without a package manager, using a ready-made *.run installer from the vendor's website.

    To update the version of such components, they need to be reinstalled. To do this, first remove the CUDA components, and then install them again.

  5. Determine the update source and the versions available for update:

    apt-cache policy cuda-toolkit-<MAJOR_VERSION>-<MINOR_VERSION> \   cuda-libraries-<MAJOR_VERSION>-<MINOR_VERSION> \   cuda-runtime-<MAJOR_VERSION>-<MINOR_VERSION> \   cudnn9-cuda-<MAJOR_VERSION>-<MINOR_VERSION>

    Here <MAJOR_VERSION> and <MINOR_VERSION> are the major and minor version numbers of the CUDA components. For example, for CUDA Toolkit 12.4, the package name is cuda-toolkit-12-4.

    If the output shows an Unable to locate package error, or the Candidate or Installed field shows a version from the Ubuntu (archive.ubuntu.com) or Debian (deb.debian.org and security.debian.org) repositories, it's better to switch to the NVIDIA CUDA repository (developer.download.nvidia.com) and reinstall the CUDA components instead of updating. To do this, first remove CUDA Toolkit, and then install it again.

  6. Update the CUDA components:

    sudo apt install --only-upgrade -y \   cuda-toolkit-<MAJOR_VERSION>-<MINOR_VERSION> \   cuda-runtime-<MAJOR_VERSION>-<MINOR_VERSION> \   cuda-libraries-<MAJOR_VERSION>-<MINOR_VERSION> \   cudnn9-cuda-<MAJOR_VERSION>-<MINOR_VERSION>

    Here <MAJOR_VERSION> and <MINOR_VERSION> are the major and minor version numbers of the CUDA components. For example, for CUDA Toolkit 12.4, the package name is cuda-toolkit-12-4.

Was this article helpful?