2

I have installed the NVIDIA drivers for my system (Ubuntu 22) as follows:

Reboot the system in non-graphical mode:

sudo systemctl set-default multi-user.target
reboot 0

Run install script.

Reboot in graphical mode:

sudo systemctl set-default graphical.target
reboot 0

I would like to install a matching version of the nvidia-cuda-toolkit, but I'm not sure how. I don't think my package manager (apt) will work since I did not install cuda through apt. Furthermore, I tried installing through the website:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda

but this just broke my local CUDA installation. How can I install the correct (matching) version of nvidia-cuda-tookit?

1
  • 1 : Why did you bypass your package manager for installing CUDA ? 2 : Your "local" installation ? Do you mean you get some other version installed systemwide ? 3 : I cannot tell for Ubuntu but, generally, distributions do not support installation of the nvidia-drivers by other means that their package manager. Why did you opt for bypassing it starting from the driver ? 4/ Prior to this install you start with, what was the version of Linux, nvidia-drivers and CUDA that was working on your system ?
    – MC68020
    Sep 24, 2022 at 7:39

1 Answer 1

2

Since no answer to my comment, I will assume that there is no valid reason for bypassing the package manager straight from the beginning which consists in installing the nvidia proprietary drivers.
Considering this very particular part of software, the known and recurrent problems of one given version with some given version of the kernel, with some given version of xorg… best is to leave the package manager dealing with all that compatibility problems you are actually facing.
Therefore, instead of running the nvidia installer script, (for ubuntu) do prefer :

$ sudo ubuntu-drivers autoinstall

In order to automatically install the recommended version (which is likely to be the latest stable compatible with your hardware) or

$ sudo apt install nvidia-driver-somepreciseversion

If you get any valid reason for not choosing the recommended version. (Take care to first check that somepreciseversion is made available in the repository for your specific hardware by running the ubuntu drivers command.)


Now regarding the nvidia-cuda-toolkit you want to install… what about going on the same way ?

Be aware that even nvidia recommends preferring the distro-specific package to their distribution agnostic download.

The distribution-independent package has the advantage of working across a wider set of Linux distributions, but does not update the distribution's native package management system. The distribution-specific packages interface with the distribution's native package management system. It is recommended to use the distribution-specific packages, where possible.

Therefore, (on Ubuntu) simply fire

$ sudo apt install nvidia-cuda-toolkit

And forget whatever about any compatibility problem.


Of course and, at your own unsupported risks, you might want running a more recent version of the toolkit than the one suggested by your package manager.
BTW, strictly follow the instructions and checklist provided by nvidia
If there is some part you hardly understand please do not hesitate to ask as part of a comment.

However, for having just checked, latest available versions in ubuntu repo being 11.5, Is the 11.7 (latest upstream dev version) actually worth the extra gray hairs… ;-)


Note : I do acknowledge this answer does not meet the special requirements made for the bounty. However, since nvidia-cuda-toolkit 11.x is claimed compatible with >= 450.80.02 nvidia-drivers version and OP reported having installed 515.65, there should get nothing to worry about drivers incompatibility, even going with the .run.
Moreover, I understand that OP (Who do not tell if the 515 is actually compatible with their hardware/kernel/xorg) more facing trouble with some local ??? cuda install being possibly broken by its later install of the nvidia-cuda-toolkit. (irrespective of the drivers)
Being said that whatever nvidia-cuda-toolkit install made thanks to the nvidia installer breaking whatever version already installed via the package manager would be nothing but normal.

2
  • This answer explicitly does not answer my bounty / the original question, which was to install matching CUDA toolkit for an NVIDIA driver version that was installed without the package manager. This is an important distinction, and if I could withdraw the bounty I would.
    – Foobar
    Sep 30, 2022 at 6:09
  • @Foobar giving a bounty is a wager: there is no guarantee that you will get the answer you want and the rep is lost as soon as the bounty is offered. That's just the way the system works: you bet, you lost.
    – terdon
    Oct 2, 2022 at 12:17

You must log in to answer this question.