ubuntu16 uninstall and install new nvidia driver, cuda, cudnn

1. Uninstall nvidia driver

My computer configuration:

卡: Geforce gtx 650
ubuntu 16.04

I installed nvidia384.130, cuda9.0 and cudnn7 before. When reproducing pointnet, it prompts that the driver version is too old and can only be uninstalled and reinstalled.
Uninstall the driver:

sudo apt-get remove --purge nvidia*

To install the new version of the driver, I directly select 440 in System Settings-Software and Updates-Additional Drivers, and click Apply Changes, as shown in the following figure:
Insert picture description here

2. Uninstall the old cuda, install the new cuda 10.2

After installing the 440.100 nvidia driver, you can find the corresponding cuda version 10.2 on the cuda official website. First uninstall the original cuda9.0, mainly execute the uninstall script that comes with cuda, which will be explained during installation. Note that if you want to use pytorch in the future, do not install cuda11 for the time being, the reasons will be explained later.

sudo /usr/local/cuda-9.0/bin/uninstall_cuda_9.0.pl

After uninstalling, there will be a prompt that there is a folder that has not been uninstalled cleanly. Some files corresponding to cudnn can be used with the following command:

sudo rm -rf /usr/local/cuda-9.0/

Install the new cuda, go directly to the official website cuda to select the corresponding version, and download the .run file to install it according to the command given on the official website. Note that you need to modify the permissions of the run file first.

sudo chmod a+x cuda_10.2.89_440.33.01_linux.run

Configure environment variables:

sudo gedit ~/.bashrc
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc

Use nvcc --version to check whether the installation is successful.

3. Uninstall the old cudnn and install the new cudnn

Generally, the folder corresponding to cudnn has been uninstalled when cuda is uninstalled. You can view the following two folders and delete them if they are still in use.

sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/loca/cuda/lib64/libcudnn*

Install the new cudnn, download the cuda10.2 version of cudnn8 from https://developer.nvidia.com/cudnn , select cudnn library for linux (x86) to download, unzip the file to get the cuda folder, enter the folder, and press the following Command to copy the software package.

sudo cp include/cudnn.h /usr/local/cuda/include/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo cp lib64/lib* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

4. Configure the corresponding pytorch-gpu

Previously, a pytorch virtual environment was created with anaconda according to the original computer configuration, and pytorch-gpu version 1.10 was installed. Now you need to delete this environment and install a new one.

conda remove -n pytorch --all  //卸载conda虚拟环境

Create another virtual environment

conda create -n pytorch python=3.7

Search for the newly configured pytorch on the pytorch official website and install it according to the official website command. A little attention is needed here, cuda11 has been released, but pytorch does not have a version corresponding to cuda11, the highest is only cuda10.2.

Guess you like

Origin blog.csdn.net/qq_43265072/article/details/108095443