Windows下如何安装cuDNN

我在安装了CUDA之后,发现cuDNN忘记安装了,tensorflow一定要安装这个才行,由于电脑有点老了,CUDA也不是最新的11,tensorflow还停留在1.XX时代。

首先现在这个地址上面下载cuDNN,注意对应自己的CUDA版本才行,需要登陆英伟达账号进行下载,本人下载了几个可以直接使用,传到了博客的下载目录里面。

https://developer.nvidia.com/rdp/cudnn-archive

解压完成后主要有三个目录bin/   include/  lib/x64/把他们其中的内容分别丢到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1的三个同名分级目录下(以个人实际的CUDA安装目录为准)

之后就可以拿tensorflow试着写一个hello world了

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello)) # output Hello, TensorFlow! 

也可以用tensorflow看看是否可以用GPU

import tensorflow as tf

gpu_device_name = tf.test.gpu_device_name()
print(gpu_device_name)

会生成中间信息

2021-02-15 00:58:03.346933: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic
library nvcuda.dll
2021-02-15 00:58:03.373643: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: GeForce GTX 960M major: 5 minor: 0 memoryClockRate(GHz): 1.176
pciBusID: 0000:01:00.0
2021-02-15 00:58:03.373887: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are s
tatically linked, skip dlopen check.
2021-02-15 00:58:03.374227: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2021-02-15 01:01:08.960541: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor
with strength 1 edge matrix:
2021-02-15 01:01:08.960772: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
2021-02-15 01:01:08.961241: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
2021-02-15 01:01:08.964950: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:
GPU:0 with 3048 MB memory) -> physical GPU (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capabil
ity: 5.0)

然后输出

/device:GPU:0

或者使用 tf.test.is_gpu_available() 判断gpu是否可用

返回

True


0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用 * 标注