nvidia 3060 + cuda + cudnn + tf

参考: https://eipi10.cn/deep-learning/2019/11/28/centos_cuda_cudnn/
1.环境版本:
CentOS Linux release 7.8.2003 (Core)
Tensorflow-gpu 2.5
nvidia 3060
cuda 11.2.2
cudnn-11.3

2.环境检查:

lscpi | grep -i nvidia  # 要有nvidia 设备

3.首先安装nvidia-3060的驱动:
下载驱动:
nvidia 3060 + cuda + cudnn + tf_第1张图片
4.设置linux运行级别临时为文本模式:
systemctl set-default multi-user.target
5.运行脚本驱动安装驱动:

bash NVIDIA-Linux-x86_64-525.85.05.run

6.设置linux运行级别恢复为图形模式:
systemctl set-default graphical.target

7.下载cuda安装软件:
wget https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run
8.运行脚本安装软件

bash cuda_11.2.2_460.32.03_linux.run

9.修改~/.bashrc 文件

# 在~/.bashrc 新增下面内容
# cuda
export PATH="$PATH:/usr/local/cuda/bin"
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

# 执行文件
source  ~/.bashrc

10.下载cudnn程序,(地址:https://developer.nvidia.com/rdp/cudnn-archive):
cudnn-11.3-linux-x64-v8.2.1.32.tgz
11.解压并将链接库加入到环境中:

tar -xzvf cudnn-11.3-linux-x64-v8.2.1.32.tgz
cp cuda/include/cudnn*.h /usr/local/cuda/include 
cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 
chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

12.安装tensorflow-gpu==2.5.0 版本
测试代码:

import tensorflow as tf
from tensorflow.python.client import device_lib
import os

print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 不显示等级2以下的提示信息
print('GPU', tf.test.is_gpu_available())

a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)

你可能感兴趣的:(tensorflow,python,深度学习)