Uninstall previous cuda version

I want to uninstall cuda 9.1 since I just installed cuda 10. How would I do this ?

phung@UbuntuHW15:~/Downloads/pytorch$ sudo apt-get remove --purge cuda

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages were automatically installed and are no longer required:

cuda-10-0 cuda-command-line-tools-10-0 cuda-compiler-10-0 cuda-cublas-10-0

cuda-cublas-dev-10-0 cuda-cudart-10-0 cuda-cudart-dev-10-0 cuda-cufft-10-0

cuda-cufft-dev-10-0 cuda-cuobjdump-10-0 cuda-cupti-10-0 cuda-curand-10-0

cuda-curand-dev-10-0 cuda-cusolver-10-0 cuda-cusolver-dev-10-0

cuda-cusparse-10-0 cuda-cusparse-dev-10-0 cuda-demo-suite-10-0

cuda-documentation-10-0 cuda-driver-dev-10-0 cuda-drivers cuda-gdb-10-0

cuda-gpu-library-advisor-10-0 cuda-libraries-10-0 cuda-libraries-dev-10-0

cuda-license-10-0 cuda-memcheck-10-0 cuda-misc-headers-10-0 cuda-npp-10-0

cuda-npp-dev-10-0 cuda-nsight-10-0 cuda-nsight-compute-10-0 cuda-nvcc-10-0

cuda-nvdisasm-10-0 cuda-nvgraph-10-0 cuda-nvgraph-dev-10-0 cuda-nvjpeg-10-0

cuda-nvjpeg-dev-10-0 cuda-nvml-dev-10-0 cuda-nvprof-10-0 cuda-nvprune-10-0

cuda-nvrtc-10-0 cuda-nvrtc-dev-10-0 cuda-nvtx-10-0 cuda-nvvp-10-0

cuda-runtime-10-0 cuda-samples-10-0 cuda-toolkit-10-0 cuda-tools-10-0

cuda-visual-tools-10-0 dkms freeglut3 freeglut3-dev libglu1-mesa-dev

libnvidia-cfg1-410 libnvidia-common-410 libnvidia-decode-410

libnvidia-encode-410 libnvidia-fbc1-410 libnvidia-gl-410 libnvidia-ifr1-410

libxmu-dev libxmu-headers libxnvctrl0 libxt-dev nvidia-compute-utils-410

nvidia-dkms-410 nvidia-driver-410 nvidia-kernel-common-410

nvidia-kernel-source-410 nvidia-modprobe nvidia-prime nvidia-settings

nvidia-utils-410 screen-resolution-extra xserver-xorg-video-nvidia-410

Use 'sudo apt autoremove' to remove them.

The following packages will be REMOVED:


0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.

After this operation, 25.6 kB disk space will be freed.

Do you want to continue? [Y/n] n


phung@UbuntuHW15:~/Downloads/pytorch$ cat /usr/lib/cuda/version.txt

CUDA Version 9.1.85

phung@UbuntuHW15:~/Downloads/pytorch$ cat /usr/local/cuda-10.0/version.txt

CUDA Version 10.0.130

phung@UbuntuHW15:~/Downloads/pytorch$ /usr/bin/nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation

Built on Fri_Nov__3_21:07:56_CDT_2017

Cuda compilation tools, release 9.1, V9.1.85

phung@UbuntuHW15:~/Downloads/pytorch$ which nvcc



I have just removed my freshly installed cuda-10 and now working on uninstalling cuda-9.1 which I had difficulty at.

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile-uninstallation does not help because the pl script is not found.

phung@UbuntuHW15:~/Downloads/pytorch$ ls -al /usr/local/cuda/

total 16

drwxr-xr-x 4 root root 4096 Sep 27 13:11 .

drwxr-xr-x 13 root root 4096 Nov 14 21:00 ..

drwxr-xr-x 2 root root 4096 Sep 27 13:12 include

drwxr-xr-x 2 root root 4096 Sep 27 13:12 lib64


https://askubuntu.com/questions/530043/removing-nvidia-cuda-toolkit-and-installing-new-one seems to have solve my problem

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

But when I run nvidia-smi , I have the following problem:

phung@UbuntuHW15:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
phung@UbuntuHW15:~$ nvidia-modprobe
phung@UbuntuHW15:~$ nvidia-smi
Failed to initialize NVML: Driver/library version mismatch
phung@UbuntuHW15:~$ sudo aptitude install nvidia-driver-410
nvidia-driver-410 is already installed at the requested version ([b]410.48[/b]-0ubuntu1)
nvidia-driver-410 is already installed at the requested version (410.48-0ubuntu1)
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

phung@UbuntuHW15:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module [b]390.77[/b] Tue Jul 10 18:28:52 PDT 2018
GCC version: gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
phung@UbuntuHW15:~$ grep-dctrl -sPackage . /var/lib/apt/lists/ppa.launchpad.net_*_Packages
Package: gdb
Package: hello
Package: gdb-doc
Package: gdb-source
Package: gdbserver
Package: gdb-multiarch
Package: gdb-dbg
Package: gdb
Package: hello
Package: gdb-doc
Package: gdb-source
Package: gdbserver
Package: gdb-multiarch
Package: gdb-dbg