Cannot Purge and Install NVIDIA driver

Iman - thank you so much for posting your resolution to this. Ran into this on Ubuntu 18.04.

Also can confirm this has nothing to do with exiting the GUI as I encountered these errors in tty2, after killing lightdm.

I was going absolutely nuts as I was stuck in the same situation as you - I couldn’t run ‘sudo apt-get remove --purge nvidia-*’ as I’d get a ton of these dependency errors, and if I tried to run ‘sudo apt-get -f install’ I’d get the same “Sub-process /usr/bin/dpkg returned an error code (1)” message as you.

In case it’s not 100% clear from Iman’s post, as it took me some time to understand what they meant - what you have to do is run

sudo dpkg --force-all -P [name of package with unmet dependency]

one by one until you’ve removed all the offending packages with unmet dependencies. So for example based on Iman’s errors you’d do

sudo dpkg --force-all -P cuda-cudart-dev-8-0

then

sudo dpkg --force-all -P cuda-cufft-dev-8-0

then

sudo dpkg --force-all -P cuda-cusolver-dev-8-0

etc etc until you’ve made your way down the whole list. Once all the packages with missing dependencies are all gone you can finally run the ‘sudo apt-get remove --purge nvidia-*’ command again, and it’ll succeed this time. You can then do a clean install of whatever CUDA/NVIDIA driver you need.

Couldn’t find anything about this on StackOverflow or Github…so glad you made this thread, was afraid I’d just have to do a fresh Ubuntu install…thanks again Iman!! :)

1 Like