I'm working with Ubuntu 16 and Cuda toolkit 10.2.

I'm using installer file: cuda_10.2.89_440.33.01_linux.run.

I understand I need to remove something I previously installed but don't know what exactly.

Any suggestions will be appreciated.

  • 2
    Why do you expect to need to remove a previously installed package? What was that package? Which Ubuntu is installed; 16.04 or 16.10 ? Are you using virtualization, and if so, which package? Please click edit and add that vital information to your question so all the facts we need are in the question. Please do not use Add Comment.
    – K7AAY
    Feb 20, 2020 at 19:12
  • 2
    I just got the same message. Just in case anyone wonders, right after "driver found," the messages says something like "YOU ARE STRONGLY ENCOURAGED TO ABORT." So that explains the 'need to remove a previously installed package...'
    – shmim
    Nov 21, 2020 at 0:27

4 Answers 4


If you only want to install the cuda toolkit to /usr/local, please run:

sudo sh ./cuda_10.2.<spec>.run --toolkit --silent --override

If you need nvidia driver as well, you could try the answer provided by Albino Cordeiro

Running dpkg -l | grep Nvidia and then sudo apt purge ... did the trick.

Warning: above will uninstall your current nvidia driver.


Just run into this exact problem in Ubuntu18.04. And after some search, my solution is the following:

  1. If you are sure that your driver version matches the cuda-toolkit version you are gonna install, refer to @domainxz answer, add --toolkit to only install toolkit and not to care about nvidia driver. Check this link for compatibility. (Scroll down to CUDA Driver table).

  2. If you want CUDA to handle the compatibility problem for you, you need to uninstall your current drivers. Follow the instructions in the official documentation. After you entered the text screen after reboot, uninstall your previous Nvidia driver and run the cuda runfile. For Ubuntu 18.04, what I did and worked:

    sudo apt-get remove --purge nvidia\*
    sudo apt-get autoremove
    sudo sh cuda-*.run --silient --override

The official documentation is actually very detailed... Just make sure you follow each step and you should be fine.

  • 4
    I had to purge the following patterns as well: \*nvidia\*, \*cuda\*, \*nvrtc\*
    – serg06
    Jan 7, 2022 at 21:25

I managed to solve my problem. I manage a large number of identical servers and usually use a .run file (cuda_10.2.89_440.33.01_linux.run) to install the Cuda toolkit. On this one specific server, I did some experiments a while ago and forgot that I installed the previous version of Cuda differently there (using sudo apt install). Running dpkg -l | grep Nvidia and then sudo apt purge ... did the trick.

  • 9
    did you mean - dpkg -l | grep nvidia May 4, 2020 at 12:23
  • 3
    purge what?....
    – Ahmad
    Jun 27, 2020 at 7:08
  • 1
    purge cuda, so you can install the newer version using the .run file. Jun 29, 2020 at 20:15
  • 4
    I get a list of 25 lines (e.g., nvidia-cuda-dev, libnvidia-common-440...) you mean purge all?
    – sAguinaga
    Jul 3, 2020 at 15:58
  • 1
    In my case, that's what I did. Aug 18, 2020 at 18:08

got in rootm with

$ sudo su


# for FILE in $(dpkg-divert --list | grep nvidia-340 | awk '{print $3}'); do dpkg-divert --remove $FILE; done


# apt --fix-broken install

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .