Need Help Cleaning Up Nvidia Third-Party Repo and Drivers

Ubuntu Version:
25.10

Desktop Environment (if applicable):
KDE Plasma

Problem Description:
Hi all,

I’ve been trying to make cuda toolkit work with ubuntu for llm purposes and made a mess in the process.

Background

I was setting up my ubuntu for llama.cpp using this guide, which requires installing cuda-toolkit from nvidia’s ppa:

https://balaakshay.medium.com/beginners-guide-setting-up-llama-cpp-for-local-llm-experiments-gpu-optimized-291adc5b7ba2

Tried it but failed trying to build from source due to a toolchain issue when running cmake (something about incompatible glib and cuda versions requiring naive patch to the math functions).

Only much later did I realize that ubuntu’s official repo already supports cuda-toolkit simply by running apt install nvidia-cuda-toolkit.

Now I have multiple repos for nvidia drivers (ubuntu’s repo and nvidia’s ppa), which is getting confusing. I updated to the latest nvidia driver (595.45.04), thinking that it came from ubuntu’s original repo (it was from nvidia’s repo instead). The update is awesome, but might cause instability down the line.

Question

I want to clean up all the mess I made (remove nvidia repo and drivers I installed through their repo), and return to the original state for easier management.

I’ve been reading around online and people often recommend purging all nvidia drivers (including cuda drivers), removing the nvidia repo, and then reinstalling the drivers using ubuntu-drivers install

Is this the proper solution, or is there a better approach?

Thanks!

Relevant System Information:
Nvidia RTX 5060 Ti (16gb)

Driver: 595.45.04

Cuda: 13.2

Secure Boot Enabled

Screenshots or Error Messages:
N/A

What I’ve Tried:
Considering the recommended approach above, but want to double check to avoid bricking my system.

As far as I am aware the ppa-purge command will remove the PPA and remove the packages from the PPA. Can someone please confirm

Hmm, the man page does say that the command “disables a PPA and reverts to official packages” (i.e., auto downgrade packages in a given PPA back to ubuntu versions).

Might try this out and see how it goes. Thanks!

UPDATE
Ran the following command

ppa-purge *cuda*

It returns the following:

PPA to be removed: developer.download.nvidia.com_compute_cuda_repos_ubuntu2404_x86%5f64_InRelease ppa
Warning: Could not find package list for PPA: developer.download.nvidia.com_compute_cuda_repos_ubuntu2404_x86%5f64_InRelease ppa

The PPA listed checks out at first glance. However, the command failed since it couldn’t find package list for the PPA, which is odd since I installed cuda-toolkit and the new driver through the PPA. Any idea what happened?

Welcome to Ubuntu Discourse :slight_smile:

The following guide explains how to use ppa-purge

Make sure important data is backed up before making any major system changes.

Hi, thanks for the guide!

However, I’m still confused on how to use it.

Looking at the guide and other examples online, the naming format for the args (i.e., ppa:example/ppa-name) seems to be based on ppas provided by ppa.launchpad.net. However, the nvidia repo I added is maintained by nvidia (developer.download.nvidia.com_compute_cuda_repos_ubuntu2404_x86%5f64_InRelease).

Can I still make it work? or am I missing something?

Thanks!

Seems there was a misunderstanding on my part. Those do not appear to be Launchpad repositories.

Let’s check and make sure what is going on before the next steps.

Show us the output from these commands:

nvidia-smi
apt policy nvidia-driver-595
ls /etc/apt/sources.list.d/

Thanks

UPDATE
Decided to just bite the bullet and go for the documented approach. Here’s what I did:

Step 1: remove Cuda as per Nvidia’s official documentation

apt remove --purge "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"

Check apt policy to confirm if Nvidia’s repo has been removed.
Works. reboot

Step 2: remove all nvidia drivers

apt-get purge *nvidia*
apt autoremove
reboot

Black screen on boot, which is exactly as expected considering it’s a well known issue with Ubuntu and Nvidia drivers. So black screen is a good sign.

Restarted, pressed “e” on grub menu to configure boot settings. Changed “no splash” to “nomodeset”.

Successfully booted.

Step 3: reinstall Nvidia drivers (and failed)

ubuntu-drivers install

returns an error at the end related to dkms (forgot to take notes of what it said, sorry)

Ran nvidia-smi to check drivers. Says there might be an error with the driver.

Ran sudo apt --fix-broken install, it failed to install libnvidia-cfg1 dependency.

Step 4: fix Nvidia drivers
Looked up similar issues online, found this discussion.

Ran the recommended command:

apt-get --autoremove purge '*nvidia*' '*nvidia*:i386' '*cuda*' '*cuda*:i386'

reboot with nomodeset again

ran ubuntu-drivers install, reboot without nomodeset, Successful.

Ran nvidia-smi and now we’re back on driver 580 (perfectly fine tbh, and it’s the de facto most stable latest driver so far anyways)

Ran apt full-upgrade just because, and I’m back to driver 590 that I started out with before I made a mess of my system.

Lesson learned: always check around if a package is officially supported before adding third-party repo.

In hindsight, that would be the right approach. However, there’s no official documentation on Ubuntu’s official cuda-toolkit in either Nvidia’s documentation (which still recommends using their own repo) or Ubuntu’s.

Might be worth to consider communicating the official cuda-toolkit support more to avoid unnecessary headaches for the users.

All in all, everything seems to be working fine so far. Installed Cuda with apt install nvidia-cuda-toolkit with no issue. Here’s hoping I didn’t cause any breakage just waiting to show itself. If anyone here noticed that I did something wrong or my approach might cause issues, do let me know!

Thank you all for the help!

1 Like

Hi, thanks for the help!

Decided to test out the solutions I found online instead. Ran through some problems, which has now been (hopefully) resolved. Check my previous message if you’re curious.

1 Like

Great share. Hopefully it’ll help others