admin管理员组文章数量:1534845
Win10下安装tensorflow教程
目录
一、环境配置
二、安装python3.5.2
三、安装Anaconda3.4.1
四、安装cpu版本的tensorflow
五、安装GPU版本的tensorflow,即tensorflow-gpu
一、环境配置
1、win10-64位系统
2、python 3.5.2 (官网下载链接:https://www.python/downloads/release/python-352/)
3、anaconda 4.3.14
(清华镜像下载链接:https://mirrors.tuna.tsinghua.edu/anaconda/archive/)
(官网下载链接:https://www.anaconda/download/)
4、VS2015 (VS2015下载参考网址)
(vs_community__21855616.1542252661.exe)
(社区版下载地址:http://download.microsoft/download/B/4/8/B4870509-05CB-447C-878F-2F80E4CB464C/vs2015_chs.iso
)
5、本机GPU显卡:NVIDIA DeForce GTX 1050
6、tensorflow 1.10.0 (参考网址:https://pypi/project/tensorflow/1.1.0rc2/#files)
7、cuda 9.0
(cuda 9.0, V9.0.176 cuda_9.0.176_win10.exe)
(官网下载地址:https://developer.nvidia/cuda-toolkit-archive)
8、cuDNN7
(cudnn-9.0-windows10-x64-v7)
(官网下载地址:https://developer.nvidia/rdp/cudnn-archive)
备注说明:
需要先查看Windows下,TensorFlow对python版本的要求(查看版本教程)
在安装cuda之前,我首先安装了VS2015 (VS2015安装教程)。但是目前我还不确定:不安装VS2015,是否也可以成功安装tesorflow-gpu。如果有哪位朋友知道,欢迎下方留言!!!
二、安装python3.5.2
Windows -64 安装python3.5.2
可知python3.5.2 自带pip8.1.1
三、安装Anaconda3.4.1
下载地址(清华镜像):https://mirrors.tuna.tsinghua.edu/anaconda/archive/
双击安装,可自定义安装路径,其他安装选项设置为默认即可;
安装完成,测试anaconda是否安装成功:
win+R打开命令行,输入如下命令:
conda -V
conda --version
可知,实际上安装的是anaconda 4.3.14
说明anaconda 4.3.14安装成功
PS:anaconda 4.3.14 自带的是python3.6
四、安装cpu版本的tensorflow
win+R打开命令行,输入如下命令:
conda create --name tensorflow python=3.5.2
activate tensorflow
conda info --envs
python --version
pip install tensorflow==1.10.0
python
import tensorflow as tf
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
最后打开anaconda prompt 进行测试
参考步骤图如下所示(部分步骤):
五、安装GPU版本的tensorflow,即tensorflow-gpu
5.1、查看本机GPU显卡类型,确认是否支持安装tensorflow-gpu
查看显卡配置是否支持安装gpu版本的tensorflow
5.2、安装tensorflow-gpu
5.2.1、注意:
安装gpu版本的tensorflow,需要安装cuda和cudnn,
并且三者的版本有一定的对应关系,
只有正确匹配的版本才能安装成功tensorflow-gpu
我的安装版本分别是:python3.5.2 + cuda9.0 + cudnn7.0
5.2.2、思路:
先安装tensorflow-gpu,然后执行测试命令,根据错误提示,逐步安装对应版本的cuda和cudnn;
5.2.3、安装步骤:
win+R打开命令行,输入如下命令:
conda info --envs (查看conda环境信息)
conda create --name tensorflow-gpu python=3.5.2 (使用conda新建tensorflow-gpu环境,python选择3.5.2版本)
conda info --envs (查看conda目前的环境都有哪些)
activate tensorflow-gpu (激活新创建的tensorflow-gpu)
conda info --envs (再次确认conda目前的环境都有哪些)
python --version (再次确认tensorflow-gpu环境下python的版本)
pip install tensorflow-gpu==1.10.0 (pip安装指定版本的tensorflow-gpu,这里安装1.10.0版本)
python
import tensorflow as tf
报错,根据提示,需要安装cuda9;
下载安装cuda9后再次执行(cuda+cudnn安装教程):import tensorflow as tf
又报错了,根据提示需要安装cudnn7(解压复制到相应的cuda安装目录下,cuda+cudnn安装教程)
安装cudnn7后再次执行如下命令:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
成功执行。
最后,打开Anaconda Prompt测试是否安装成功,
正确尝试:进入Anaconda Prompt-python里
输入:activate tensorflow-gpu 的环境,键入python,然后再键入import tensorflow as tf
测试命令如下:
conda info --envs
activate tensorflow-gpu
python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
参考过程如下图(部分步骤截图):
说明tensorflow-gpu安装成功。
打开Anaconda Prompt测试是否安装成功:
显示结果。说明安装成功!!
参考教程:https://m.aliyun/yunqi/articles/423513
六、命令总结
下载安装python3.5.2
自带pip,查看可升级pip
win+R
python --version
python -V
pip -V
python -m pip install --upgrade pip
安装anaconda 4.3.14 (自带python3.6)
自定义安装目录,其他默认安装即可
安装时选择自动加入环境变量
win+R
conda -V
conda --version
conda info --envs
conda create --name tensorflow-gpu python=3.5.2
activate tensorflow-gpu
conda info --envs
python --version
pip install tensorflow-gpu==1.10.0
python
import tensorflow as tf
此时会报错,根据提示,需要安装cuda9
安装cuda9后再次执行
import tensorflow as tf
又报错了,根据提示需要安装cudnn7(解压文件并复制到相应的cuda安装目录下)
安装cudnn7后再次执行
import tensorflow as tf
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
正确输出结果
安装tensorflow-gpu成功
打开ananconda prompt 进行测试
conda info --envs
activate tensorflow-gpu
python --version
python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
正确输出结果,则说明安装成功!
退出python:quit() 或exit() 或ctr+z
deactivate
安装tesorflow环境,即cpu版本的tensorflow
win+R
conda -V
conda --version
conda info --envs
conda create --name tensorflow python=3.5.2
activate tensorflow
conda info --envs
python --version
pip install tensorflow==1.10.0
python
import tensorflow as tf
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
打开ananconda prompt 进行测试
conda info --envs
activate tensorflow
python --version
python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
正确输出结果,则说明安装成功!
退出python:quit() 或exit() 或ctr+z
deactivate
测试tensorflow是否安装成功:
win+R
cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\demo_suite
bandwidthTest
deviceQuery
其他命令:
win+R
查看conda支持的python版本:conda search --full-name python
查看cuda的版本:nvcc -V
卸载指定版本的tensorflow-GPU:pip uninstall tensorflow-gpu-1.5.0
选择安装版本:pip install tensorflow-gpu==1.4.0
获取tensorflow版本号:import tensorflow -》回车 -》tensorflow.__version__
安装特定版本:
pip install tensorflow==1.2.0
升级到最新版本:
pip install –upgrade tensorflow
安装与卸载tensorflow-gpu:
pip install tensorflow-gpu==1.2.1
pip uninstall tensorflow-gpu==1.2.1
安装与卸载keras同样:
pip install keras==2.0.5
pip uninstall keras=2.0.5
Anaconda创建和删除环境
conda create -n py36 python=3.6
conda remove -n py36 --all
Anaconda创建环境
对于GPU版本:conda create --name tensorflow-gpu python=3.5.2
对于CPU版本:conda create --name tensorflow python=3..5.2
七、参考链接
https://blog.csdn/Eppley/article/details/79297503
http://blog.51cto/acevi/2103437
https://www.tensorflow/install/install_windows?hl=zh-cn
https://mirrors.tuna.tsinghua.edu/tensorflow/windows/cpu/
https://blog.csdn/ygjustgo/article/details/78883981
https://blog.csdn/sb19931201/article/details/53648615
https://blog.csdn/u010618587/article/details/82940528
https://blog.csdn/asd136912/article/details/79383161
https://developer.nvidia/?destination=node/872758
https://developer.nvidia/rdp/cudnn-archive
https://mirrors.tuna.tsinghua.edu/tensorflow/windows/cpu/
https://developer.nvidia/cuda-toolkit-archive
https://blog.csdn/weixin_39290638/article/details/80045236
https://pypi/project/tensorflow/1.1.0rc2/#files
https://blog.csdn/shuiyuejihua/article/details/78738664
https://wwwblogs/myblog1993/p/6931007.html
https://blog.csdn/chduguxue/article/details/79392220
https://blog.csdn/chduguxue/article/details/79392220
https://www.python/downloads/release/python-350/
https://mirrors.tuna.tsinghua.edu/anaconda/archive/
https://wwwblogs/lvsling/p/8672404.html
https://pypi/project/tensorflow/1.1.0rc2/
https://www.python/downloads/windows/
https://blog.csdn/Eppley/article/details/79297503
https://mirrors.tuna.tsinghua.edu/tensorflow/windows/cpu/
https://wwwblogs/lvsling/p/8672404.html
本文标签: 版本教程tensorflowCPUGPU
版权声明:本文标题:Win10下安装tensorflow教程(cpu版本和GPU版本) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1726891765a1088903.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论