I installed the CUDA 5.5 package on Ubuntu 14.04 (which is not supported for this version of Ubuntu version) , and I didn't do it well.

I want to remove what I've installed earlier and install a new CUDA 6.5 toolkit,

After typing this in the terminal: dpkg -l | grep -i nvidia,

I get the following output:

ii  bbswitch-dkms                                         0.8-1~trustyppa1                                    all          Interface for toggling the power on NVIDIA Optimus video cards
ii  bumblebee                                             3.2.1-90~trustyppa1                                 amd64        NVIDIA Optimus support
ii  bumblebee-nvidia                                      3.2.1-90~trustyppa1                                 amd64        NVIDIA Optimus support using the proprietary NVIDIA driver
ii  libcublas5.5:amd64                                    5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA BLAS runtime library
ii  libcuda1-331                                          331.38-0ubuntu7.1                                   amd64        NVIDIA CUDA runtime library
ii  libcudart5.5:amd64                                    5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA runtime library
ii  libcufft5.5:amd64                                     5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA FFT runtime library
ii  libcufftw5.5:amd64                                    5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA FFTW runtime library
ii  libcuinj64-5.5:amd64                                  5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA INJ runtime library (64-bit)
ii  libcurand5.5:amd64                                    5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA Random Numbers Generation runtime library
ii  libcusparse5.5:amd64                                  5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA Sparse Matrix runtime library
ii  libnppc5.5:amd64                                      5.5.22-3ubuntu1                                     amd64        NVIDIA Performance Primitives core runtime library
ii  libnppi5.5:amd64                                      5.5.22-3ubuntu1                                     amd64        NVIDIA Performance Primitives for image processing runtime library
ii  libnpps5.5:amd64                                      5.5.22-3ubuntu1                                     amd64        NVIDIA Performance Primitives for signal processing runtime library
ii  libnvtoolsext1:amd64                                  5.5.22-3ubuntu1                                     amd64        NVIDIA Tools Extension
ii  libnvvm2:amd64                                        5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA Compiler NVVM runtime library
ii  nvidia-331                                            331.38-0ubuntu7.1                                   amd64        NVIDIA binary driver - version 331.38
ii  nvidia-cuda-dev                                       5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA development files
ii  nvidia-cuda-doc                                       5.5.22-3ubuntu1                                     all          NVIDIA CUDA and OpenCL documentation
ii  nvidia-cuda-gdb                                       5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA GDB
ii  nvidia-cuda-toolkit                                   5.5.22-3ubuntu1                                     amd64        NVIDIA CUDA toolkit
ii  nvidia-libopencl1-331                                 331.38-0ubuntu7.1                                   amd64        NVIDIA OpenCL Driver and ICD Loader library
ii  nvidia-nsight                                         5.5.22-3ubuntu1                                     amd64        NVIDIA Nsight Eclipse Edition
ii  nvidia-opencl-dev:amd64                               5.5.22-3ubuntu1                                     amd64        NVIDIA OpenCL development files
ii  nvidia-opencl-icd-331                                 331.38-0ubuntu7.1                                   amd64        NVIDIA OpenCL ICD
ii  nvidia-profiler                                       5.5.22-3ubuntu1                                      amd64        NVIDIA Profiler for CUDA and OpenCL
ii  nvidia-settings                                       331.20-0ubuntu8                                     amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-visual-profiler                                5.5.22-3ubuntu1                                     amd64        NVIDIA Visual Profiler
ii  primus

I'd like to remove only what is needed to install the newest CUDA toolkit. Packages, like bumblebee, I want to remain as they are.

Which packages should I remove and which should not be removed to get this done?

8 Answers 8


This method will give a complete removal of Cuda:


remove the CUDA files in /usr/local/cuda-5.0


Uninstall just nvidia-cuda-toolkit

sudo apt-get remove nvidia-cuda-toolkit

Uninstall nvidia-cuda-toolkit and it's dependencies

sudo apt-get remove --auto-remove nvidia-cuda-toolkit

Purging config/data

sudo apt-get purge nvidia-cuda-toolkit or sudo apt-get purge --auto-remove nvidia-cuda-toolkit

Additionally, delete the /opt/cuda and ~/NVIDIA_GPU_Computing_SDK folders if they are present. and remove the export PATH=$PATH:/opt/cuda/bin and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib:/opt/cuda/lib64 lines of the ~/.bash_profile file

  • 2
    This does not remove the files for me. In fact, is seems as if the usual removal does not clean up remaining kernel modules…
    – e-sushi
    Apr 4, 2015 at 23:14
  • @marbel is there a better way?
    – Nathan
    Apr 11, 2018 at 18:14
  • @marbel, can you explain why we shouldn't use apt-get? Jan 14, 2019 at 6:46
  • @marbel saying that "this is a terrible answer" or "Just google", is the worst kind of responses that I have ever seen. If this is a terrible answer, then explain why you think so! And btw, how do you think people got here? By googling, my friend.
    – Azim
    Aug 20, 2019 at 15:01
  • You can find some answers in the nvidia forums. The "solutions" change so often that it's hard to find something reliable. For me the solution at the time was to reinstall the OS and I found this advice in the nvidia forums.
    – marbel
    Aug 20, 2019 at 16:49

For removing cuda, Nvidia has prepared a file (I presume this is a standard method). You need to change your directory to the cuda's path, which is by default /usr/local/cuda-x.y/bin; where x.y is your cuda version, you can do this by using the below command: (I have cuda 9.0=x.y)

 cd /usr/local/cuda-9.0/bin

There is a file named uninstall_cuda_9.0.pl in this directory (please note that the cuda version is 9.0, so run the uninstall_cuda_9.0.pl to remove cuda completely from your system!

chmod +x uninstall_cuda_9.0.pl
sudo ./uninstall_cuda_9.0.pl

As soon as you enter your password, the cuda files will be erased. (This may take a few minutes)

NOTE: How do you figure out which cuda has been installed on your Ubuntu system? By using the command nvcc, you can see that my cuda version is 9.0 in the last line of the nvcc result.

nvcc --version

The result will look like this:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176 

Note that the above method works if you set $PATH variable correctly, So if your nvcc command not works then please use the below command in terminal to find cuda version

ls /usr/local/ | grep cuda


I have installed cuda 10.2 on my system and it seems that there isn't uninstall_cuda_x.x.pl file, but nvidia replaced this file by cuda-uninstaller file in the same directory.

  • 23
    for me this sudo ./uninstall_cuda_9.0.pl file is not there what to do?
    – kRazzy R
    Feb 18, 2018 at 19:00
  • 1
    In 11.2 there also seems to be no "cuda-uninstaller" in "bin". Jun 14, 2021 at 9:55
  • 1
    for cuda 11.2 it is supposed to be /usr/local/cuda-11.2/bin/cuda-uninstaller (i.e. in the bin folder), according to the installation guide. i can't find it myself though. see docs.nvidia.com/cuda/cuda-installation-guide-linux/… section 2.8
    – Tare
    Nov 22, 2021 at 9:17

Make sure the method you use to install cuda toolkit. This answer is for whom use deb files to install cuda. I have no idea if this works for .run files.

sudo apt-get autoremove --purge cuda 

This can clear the cuda toolkit clearly. You can check that the folder /usr/local/cuda gone. And this command is the best choice to remove apt installed app.

But when you reinstall another version of cuda, you must use:

sudo apt-get install cuda-x.x

the version number must be included. I tried to install another version of cuda after the remove of the previous version, I find that sudo apt-get install cuda will still install the previous one.

  • Should be sudo apt-get install x-x eg: sudo apt-get install cuda-9-0 Jun 18, 2018 at 16:55
  • @coolscitist Thanks for your comment. Both works. I have checked. Jun 19, 2018 at 0:58
  • 3
    shouldn't it be something like cuda*? E.g., $ sudo apt-get --purge remove cuda* Jun 21, 2018 at 6:45
  • @GyuHyeonChoi Good suggestion. Did that work for you? If it is, that's a good option. Jun 23, 2018 at 8:49
  • Thank you. Small details in your answer saved my time.
    – smerllo
    Jul 1, 2019 at 1:53

For CUDA 10.1 or newer, try:

sudo /usr/local/cuda/bin/cuda-uninstaller

For CUDA 10.0, try:

sudo  /usr/local/cuda/bin/uninstall_cuda_10.0.pl
  • 1
    cuda 10.2 does not have either uninstall-cuda* or cuda-uninstaller. At least, I do not find them. Jan 23, 2020 at 17:36
  • 1
    @BobbiBennett Try the first command May 20, 2020 at 9:32
  • Both do not exists for 11.2. Jun 14, 2021 at 9:58


sudo apt-get --purge -y remove 'cuda*'
sudo apt-get --purge -y remove 'nvidia*'
sudo reboot

It removes any installed cuda and nvidia packages and then you can install any specific version that you like from: https://developer.nvidia.com/cuda-toolkit-archive.

  • 1
    Please don't post the same answer to multiple posts. If the questions are similar to each other and similar enough to be duplicates, please flag them as duplicates rather than reposting the same answer to multiple questions verbatim.
    – Thomas Ward
    Oct 14, 2019 at 14:28
  • This misses libcublas*.
    – Carlo Wood
    Mar 14, 2020 at 21:45

One should NOT, unlike suggested in among others the accepted answer, manually remove files that were installed with apt (from some ppa, or nvidia repository).

The correct way to uninstall just cuda and keep your nvidia drivers would be:

sudo apt purge "libcublas*" "cuda-*" cuda

Possible, because they were installed as requirements, you can also purge,

sudo apt purge "nsight-*" nvidia-modprobe

After that you can, if you want, also remove the nvidia drivers with:

sudo apt purge "*nvidia*"

Of course, if you installed cuda using nvidia's .run file then this won't work; in that case you probably have some uninstall script.


Please refer the link below, which would help you decide whether your new installation and old installation of CUDA would be conflicting or not. If they aren't conflicting, you should be able to keep both of them.

If there is already a version of CUDA installed, you can do the following:

The method of uninstalling directly depends on the method of installation, whether it was a runfile, or a deb file, etc.

Use the following command to uninstall a Toolkit runfile installation:

$ sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl

Use the following command to uninstall a Driver runfile installation:

$ sudo /usr/bin/nvidia-uninstall

Use the following commands to uninstall a Deb installation:

$ sudo apt-get --purge remove <package_name>

Nvidia conflicting installations


To remove packages without interruption (aggressive way) because there is no way others doing it.

PKG="something" ## in our case its Nvidia or/and CUDA 
for item in `dpkg -i grep ${PGK} | awk '{print $2}'` ; do dpkg --remove --force-all $item ; done 

It will remove the packages without any issues.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.