Loading

windows 下配置TensorFlow GPU版

1.安装Anaconda

官网下载地址

我默认全打勾

导入conda清华源,加快下载速度

conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config –set show_channel_urls yes

2.安装CUDA和cuDDN(坑)

CUDA下载地址 https://developer.nvidia.com/cuda-downloads
cuDDN下载地址 https://developer.nvidia.com/rdp/cudnn-download (注:必须为cuDDB5.1 for CUDA8!)

CUDA正常安装即可,将解压的cuDDN中的bin,include,lib中文件对应放置到CUDA的C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0中的bin,include,lib中,可以避免很多麻烦!

3.安装tensorflow

更换pip源:
windows

在 c:\user\username\pip\pip.ini中加入(没有自行创建)

[global]  
index-url = https://pypi.doubanio.com/simple/  
[install]  
trusted-host=pypi.doubanio.com  
disable-pip-version-check = true  
timeout = 6000

linux(ubuntu)

cd $HOME  
mkdir .pip  
cd .pip
sudo vim pip.conf  
在里面添加  
[global]  
index-url = https://pypi.doubanio.com/simple/  
[install]  
trusted-host=pypi.doubanio.com  
disable-pip-version-check = true  
timeout = 6000  
保存即可

在cmd中输入(也可在anaconda prompt):

conda create -n tensorflow python=3.5

在cmd中使用activate tensorflow进入环境,输入

python

确认为3.5版本

使用命令安装GPU版本tensorflow

pip install tensorflow-gpu

# pip install –upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.1-cp35-cp35m-win_amd64.whl

4.测试程序

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Hello, TensorFlow!
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))

到此安装完毕!

posted @ 2018-07-10 17:22  摇橙子  阅读(197)  评论(0编辑  收藏  举报