Logo

python怎么安装tensorflow-Python使用pip安装TensorFlow模块

photo

2022年04月28日

1.首先确保已经安装python,然后用pip来安装matplotlib模块。

2.进入到cmd窗口下,建议执行python -m pip install -U pip setuptools进行升级。

3.如果之前已经安装了Numpy,则需要先卸载之前的安装,因为每个Tensorflow都有一个版本的numpy对应,故要卸载之前numpy

4.接着键入python -m pip install –upgrade tensorflow 进行自动的安装,系统会自动下载安装包。

命令提交以后,你唯一能做的就是等待了。你唯一能祈祷的,就是这该死的GFW不会坏了你好事。 还好这次运气不错,一次搞定。

验证安装

在桌面上创建a.py文件,写入以下代码

importtensorflow as tfimportos

os.environ[“TF_CPP_MIN_LOG_LEVEL”]= “2”hello= tf.constant(“Hello, TensorFlow!”)

sess=tf.Session()print(sess.run(hello))

a= tf.constant(10)

b= tf.constant(25)print(sess.run(a + b))

参考:

win10安装TensorFlow填坑笔记:http://blog.csdn.net/chewinggum/article/details/70373098

【TensorFlow】Windows10 64 位下安装 TensorFlow – 官方原生支持:http://blog.csdn.net/u010099080/article/details/53418159

Windows下安装tensorflow步骤:http://blog.csdn.net/chongtong/article/details/53905625?locationNum=6&fps=1

TensorFlow 安装教程:http://blog.csdn.net/bitcarmanlee/article/details/52749488

学习:

知乎:https://www.zhihu.com/question/49909565

极客:http://wiki.jikexueyuan.com/project/tensorflow-zh/

异常处理:

下面是从网上找到的,别人在安装的过程中出现的错误或异常,以及解决方法:

后来直接pip install tensorflow,tensorflow装完,自动装numpy却报错了。因为我之前自己用了numpy,早就装了。而每个tensorflow都有一个版本的numpy对应,故要卸载之前numpy。解决方法如下

1.Exception:

Traceback (mostrecent call last):

……

PermissionError:[Errno 13]

Permission denied:”D:\software\Anaconda\Lib\site-packages\numpy\core\multiarray.cp36-win_amd64.pyd”

解决办法:关闭所有正在运行的python程序

2. Installing collected packages:numpy, tensorflow-tensorboard, tensorflow

Found existing installation: numpy 1.11.3

Uninstalling numpy-1.11.3:

Exception……

无法卸载numpy

解决办法:pip install tensorflow –ignore-installed numpy

=============================================================

官方安装链接

tensorflow 0.12.0开始支持Windows下安装了

环境要求:

Windows 64位

python 3.5

pip 9.0.1

tensorflow 0.12.0

cuda8.0

cudnn5.1

visual c++ 2015 运行时库

查看gpu是否支持cuda

安装过程:

安装python3.5

安装

升级pip

python.exe -m pip install –upgrade pip

安装tensorflow

cpu版本

pip install –upgrade tensorflow

gpu版本

pip install –upgrade tensorflow-gpu

gpu版本tensorflow安装gpu支持包

安装cuda8.0

安装

安装cudnn5.1

安装

添加解压后的bin目录到PATH环境变量

测试tensorflow

$ python

>>>import tensorflow as tf

>>>hello = tf.constant(“Hello, TensorFlow!”)

>>>sess = tf.Session()

>>>print(sess.run(hello))

b”Hello, TensorFlow!”

>>>a = tf.constant(10)

>>>b = tf.constant(32)

>>>print(sess.run(a + b))

42

>>>

另外需确认CUDA CUDNN与TensorFlow版本是否匹配

gpu使用情况查看

nvidia-smi -l # 实时返回GPU使用情况

所有附件
该文章没有附件.
本文为原创文章,请注意保留出处!
C# Int转Enum 2022年04月28日

Int-->Enum(1)可以强制转换将整型转换成枚举类型。例如:Colorscolor...C#Int转Enum

热门文章

修复群晖Synology Drive client右键菜单缺失问题 本教程主要解决windows10右键菜单中没有SynologyDrive菜单的问题,整体思路是找到...修复群晖SynologyDriveclient右键菜单缺失问题 作者:Pastore Antonio
1816 浏览量
docker如何查看一个镜像内部的目录结构及其内部都有哪些文件 前言:有时候我们会在docker上下载一个镜像,或者是上传一个镜像到docker上,甚至有时候就是在...docker如何查看一个镜像内部的目录结构及其内部都有哪些文件 作者:Pastore Antonio
1801 浏览量
configure: error: Package requirements (oniguruma) were not met configure:error:Packagerequirements(oniguruma)...configure:error:Packagerequirements(oniguruma)werenotmet 作者:Pastore Antonio
1532 浏览量
Adobe Acrobat Pro 激活 这里记录了一些AdobeAcrobat的激活教程和组件。浏览量:1,685 作者:Pastore Antonio
1531 浏览量
追寻日出,找回自己 为什么我要去追寻日出?其实我是一个很懒的人,每次都起不来,直到有一次我在租房中睡到了大天亮,阳光照...追寻日出,找回自己 作者:Pastore Antonio
1508 浏览量