PIP安装tensorflow
·
第二次安装
重新配置了一台电脑
先是提示版本低了,好吧,升级pip
You are using pip version 9.0.1, however version 21.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
执行
python -m pip install --upgrade pip
然后再输入
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
结果报错,好吧,搜索查错,然后抄作业输入这个
python -m pip --default-timeout=100 install -U tensorflow
成功了。。。。
然后
python -m pip --default-timeout=100 install -U tensorflow-gpu
安装成功,测试
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
print(tf.__version__)
a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)
>>> tf.test.is_built_with_cuda()
True
第一次安装
重点只是网络太慢而已,换成手机热点试一下。。。
pip默认的路径是python官网的下载路径,直接下载下载速度会非常慢经常超时导致安装失败。
-
使用vpn下载
-
更换pip的下载路径
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
用管理员身份执行cmd,然后输入如下命令
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/
更多推荐

所有评论(0)