在cmd输入:nvidia-smi
如果提示没有此命令,说明你要装gpu驱动了
点击这里查看
所以我选
t
e
n
s
o
r
f
l
o
w
2.7
−
p
y
t
h
o
n
3.8
−
c
u
d
a
11.2
−
c
u
d
n
n
8.1
tensorflow2.7-python3.8-cuda11.2-cudnn8.1
tensorflow2.7−python3.8−cuda11.2−cudnn8.1
cuda11.2-win10下载
3.2. 安装直接运行.exe解压安装一路next就可以了
4. 下载cudnn 4.1. 下载cudnn11.2-v8.1下载。下载cudnn需要登录。如果没有账号,先注册账号即可。
4.2. 安装- 解压下载的cudnn的zip文件
- 将文件复制到cuda的安装路径中,默认是:
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.2 - 将相关路径添加到环境变量中
- C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.2bin
- C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.2libx64
- C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.2libnvvp
使用命令:pip install tensorflow-gpu==2.7.1
import tensorflow as tf print(tf.config.list_physical_devices())
输出:
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
说明我有一张cpu和一张gpu
5.2.2. 查看是否会使用gpu计算import tensorflow as tf x = tf.constant([1]) print(x.device)
输出:
'/job:localhost/replica:0/task:0/device:GPU:0'
说明安装 t e n s o r f l o w 2.7.1 − g p u tensorflow2.7.1-gpu tensorflow2.7.1−gpu成功了,可以直接使用进行加速训练了。如果对你有参考作用的话,就点个赞帮助其他在冗余资料中苦苦搜寻的兄弟姐妹们吧。



