使用GPU跑Tensorflow代码实录

使用conda创建一个新的虚拟环境

输入 conda create -n intelligent-judge python=3.6

创建一个python版本为3.6的名字是intelligent-judge的虚拟环境

查看显卡信息

输入lspci | grep -i vga查看显卡信息

很明显是NVIDIA Quadro GP100

配置CUDA和CUDNN

本来是要去下载cuda和cudnn的,结果一看,服务器上已经有现成的了

输入

cat /usr/local/cuda/version.txt,

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

可以看到cuda是9.0.176版本的,cudnn是7.5.0版本的

所以对应版本,决定安装tensorflow gpu-1.70version

在虚拟环境中配置python包

输入source activate intelligent-judge激活虚拟环境

输入pip install tensorflow-gpu==1.7.0

安装成功

从远程库中pull下测试文件

运行,出现问题

提示cuda找不到

按照下面这篇文章进行调整

https://blog.csdn.net/qq_34374211/article/details/81018320

成功运行测试文件

运行训练文件,又出幺蛾子了

查阅官方API

原来是在tensorflow 1.7.0中tf.random.normal应该被替换为tf.random_normal

更改后运行

已经开始愉悦的训练了

猜你喜欢

转载自www.cnblogs.com/I-AM-DUMBASS/p/11452747.html