11. Nvidia graphics card driver, CUDA, cuDNN, Anaconda and Tensorflow Pytorch versions

1. Determine the version relationship

TensorFlow Pytorch launches cuda and cudnn versions, and the cuda version launches driver optional version

1. CUDA and graphics card driver
https://www.nvidia.com/Download/index.aspx
Insert image description here

Insert image description here

2. cuDNN Toolkit and CUDA version
https://developer.nvidia.com/rdp/cudnn-archive
Insert image description here
3. TensorFlow and CUDA cuDNN
https://tensorflow.google.cn/install/source?hl=en

Insert image description here
4. Pytorch and CUDA cuDNN
https://pytorch.org/
Insert image description here
Insert image description here

5、hidden
https://zhuanlan.zhihu.com/p/639184948
https://blog.csdn.net/Williamcsj/article/details/123514435

Official download address: https://developer.nvidia.com/rdp/cudnn-archive
Insert image description here

Install TensorFlow

  1. Install dependency packages
    Before installing TensorFlow, we need to install two dependency packages. Here my cuda version is 11.1, cudnn version is 8.1.0, and the download dependency package is
    libcudnn8_8.1.0.77-1+cuda11.2_amd64.deb
    libcudnn8-dev_8 .1.0.77-1+cuda11.2_amd64.deb
    official website link is as follows: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/Here
    I use wget to download:
    Reference link: https:/ /blog.csdn.net/weixin_46584887/article/details/122726278
    Official tutorial: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html
    Insert image description here

2. Installation process

Reference:
https://blog.csdn.net/m0_45447650/article/details/132058561
https://blog.csdn.net/weixin_46584887/article/details/122726278

1. Install graphics card driver

Method (1) Online installation

1. 卸载旧版本nvidia驱动
如果没有安装nvidia驱动,可直接跳过。

$ sudo apt purge nvidia*
1
2. 把显卡驱动加入PPA
$ sudo add-apt-repository ppa:graphics-drivers
$ sudo apt update
1
2
3. 查找版本库中显卡驱动
使用以下命令查看系统版本库中所有nvidia驱动的信息,根据需要选择合适的版本。

$ sudo apt-cache search nvidia
1
推荐使用以下命令,查看Ubuntu推荐的驱动版本,从中选择合适的版本。

$ ubuntu-drivers devices
参考链接:https://blog.csdn.net/qq_28256407/article/details/115548675

Method (2) Download and install
https://www.nvidia.com/Download/index.aspx
Insert image description here

You can refer to: https://blog.csdn.net/Perfect886/article/details/119109380. It used to be a run file, but now it is a def file. The Debian installation command is generally the sudo dpkg -i command.
For example: sudo dpkg -i cuda-repo--XY-local_*_x86_64.deb

2. Install CUDA

Method 1: Using run mode, you can choose whether to install the driver. Generally, you do not choose
https://developer.nvidia.com/cuda-downloads?
Insert image description here
Choose whether to install: https://zhuanlan.zhihu.com/p/501473091
Insert image description here
Configure the environment

配置环境
gedit ~/.bashrc
在打开的文件中添加
export CUDA_HOME=/usr/local/cuda-11.1
export LD_LIBRARY_PATH=${
    
    CUDA_HOME}/lib64
export PATH=${
    
    CUDA_HOME}/bin:${
    
    PATH}
链接:https://blog.csdn.net/qq_39821101/article/details/116092190

Method 2: Official tutorial: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#Reference
Insert image description here
: https://blog.csdn.net/qq_39821101/article/details/116092190
https ://blog.csdn.net/m0_45447650/article/details/132058561

3. Install cudnn

(1) Download and install: cudann
https://developer.nvidia.com/rdp/cudnn-archive
Insert image description here

2 Install the deb file (we need to install two dependency packages before installing TensorFlow)
Official download address: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/
Insert image description here

Use the following statements to install in sequence: (debain command, Ubuntu can also be used)
sudo dpkg -i libcudnn8_8.0.3.33-1+cuda11.0_amd64.deb
sudo dpkg -i libcudnn8-dev_8.0.3.33-1+cuda11.0_amd64.deb
sudo dpkg -i libcudnn8-samples_8.0.3.33-1+cuda11.0_amd64.deb

Ubuntu commands, for reference

执行以下命令:
sudo apt install ./cudnn-local-repo-ubuntu2004-*amd64.deb
sudo cp /var/cudnn-local-repo-ubuntu2004-8.4.1.88/cudnn-local-4B348671-keyring.gpg /usr/share/keyrings/
sudo apt update
#下面自动匹配版本,注意版本不对会出错
sudo apt install libcudnn8
sudo apt install libcudnn8-dev
sudo apt install libcudnn8-samples

Reference: https://zhuanlan.zhihu.com/p/126997172
https://zhuanlan.zhihu.com/p/639184948

4. Install TensorFlow

pip install -i https://mirrors.aliyun.com/pypi/simple tensorflow

#(2)查看cuda是否可用
import tensorflow as tf
print(tf.test.is_gpu_available())#如果结果是True,表示GPU可用

5. Install pytorch

pip3 install torch torchvision torchaudio

import torch
print(torch.__version__)
print(torch.cuda.is_available())

Insert image description here

3. Uninstall

1. 卸载旧版本nvidia驱动
如果没有安装nvidia驱动,可直接跳过。
$ sudo apt purge nvidia*


2、卸载cuda
#只执行这条可以
sudo apt-get autoremove nvidia-cuda-toolkit


cd /usr/local/cuda-11.1/bin
sudo ./cuda-uninstaller
sudo rm -rf /usr/local/cuda-11.1
从https://developer.nvidia.com/cuda-toolkit-archive下载对应版本的cuda
如果你之前执行过sudo apt-get install nvidia-cuda-toolkit,需要卸载:sudo apt-get autoremove nvidia-cuda-toolkit

sudo  apt-get install nvidia-cuda-toolkit
# 卸载
sudo apt-get autoremove nvidia-cuda-toolkit
在终端输入
nvcc -V
没有cuda版本信息,则卸载成功
链接:https://blog.csdn.net/qq_39821101/article/details/116092190

3、卸载cudnn
查询:
sudo dpkg -l | grep cudnn
将其全部卸载:
sudo dpkg -r libcudnn8-samples
sudo dpkg -r libcudnn8-dev
sudo dpkg -r libcudnn8

检查:
输入下面指令后,没有任何输出即卸载成功。
sudo dpkg -l | grep cudnn
接:https://blog.csdn.net/Williamcsj/article/details/123514435

Guess you like

Origin blog.csdn.net/weixin_44986037/article/details/132221693