虚拟环境+tensorflow-gpu

这么简单的环境配置搞了三天,圈内Bug太多,缺少DLL等一系列问题。总结一下,希望网友们少走弯路,亲测有效。

环境:anaconda2020.02,tensorflow-gpu:1.8.0,python3.6,cuda9.0(听说就是因为cuda是10.0以上版本pip的tensorflow-gpu会有bug),cudnn,keras2.1.6,protobuf==3.6.0,labelme=3.16.2

环境及期间遇到问题下载的东西都在下方链接,pip和.condarc文件放在:C:\Users\用户文件下:

链接:https://pan.baidu.com/s/1ioQYh4wDdDI_zF5VTeb1_Q
提取码:qbzb

1.cuda_9的exe文件进行安装(选自定义),一路next,安装完毕:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

2.Cudnn解压,把内容复制到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

2.2添加路径:用户变量增加:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

系统变量增加:

 

 

3.conda create -n tf-gpu python=3.6 #创建3.6的python虚拟环境

4.activate tf-gpu#激活此虚拟环镜

5.pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.8.0#装此版本的tfgpu

5.1在D:\Softwares\anaconda3\etc\profile.d的script文件的末尾增加:

 


export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH

export PATH=/usr/local/cuda-9.0/bin:/usr/local/cuda/bin:$PATH

 

6.验证:

import numpy
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a',dtype=tf.float32)
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b',dtype=tf.float32)
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))

ok,终于成功,难得五月的我还在家,虽然不上学,但假期总要有仪式感,该出去浪的时候就不能犹豫,哈哈哈哈哈哈,放假总是开心的。

7.tensorboard使用时老是打开空白页:不用换目录,地址用双斜杠,tensorboard --logdir=D:\\vgg_seg_net\\model完美解决

posted @ 2020-04-30 10:32  Turing-dz  阅读(561)  评论(0编辑  收藏  举报