根据官方的文档说明,根据安装的方式不同,有两种方式卸载。

  1. 用runfile安装cuda的
    Use the following command to uninstall a Toolkit runfile installation:
    $ sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl

  2. 用离线文件deb安装的cuda
    Use the following commands to uninstall a RPM/Deb installation:
    $ sudo yum remove <package_name> # Redhat/CentOS
    $ sudo dnf remove <package_name> # Fedora
    $ sudo zypper remove <package_name> # OpenSUSE/SLES
    $ sudo apt-get --purge remove <package_name> # Ubuntu

  3. 补充,卸载显卡驱动的
    Use the following command to uninstall a Driver runfile installation:
    $ sudo /usr/bin/nvidia-uninstall

注意:所以有的时候,/usr/local/cuda/bin下没有pl文件

  1. 参考ubuntu16.04 下 卸载CUDA9.1,进行卸载
    在这把它删除,在命令行中输入

sudo apt-get remove cuda*

sudo apt-get remove --purge cuda*

sudo apt-get update

然后在目录切换到/usr/local/下

cd /usr/local/

sudo rm -r cuda-9.1

搞定啦

可以重新安装其他版本啦