Tensorflow安装

本文详细介绍了在Windows 10系统中安装Tensorflow的步骤,包括Anaconda的安装与配置,设置国内镜像源,更新pip,以及安装和测试Tensorflow的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Win10系统Tensorflow安装

tips :Tensorflow 安装

一、安装Anaconda

1、从官网下载Anaconda

最新版本官网下载:(本地地址:D:\软件\Anaconda3-2019.07-Windows-x86_64.exe)

https://www.anaconda.com/distribution/

老版本下载的清华镜像网址:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2、安装Anaconda

当到选择Advanced Options时,一般勾选两个选项。

3、环境变量测试

(1)检测anoconda环境是否安装成功:

​ conda --version

(2)查看环境变量配置:

​ conda info --envs

(3)查看python版本并设置:

​ conda search --full --name python

​ conda create --name tensorflow python=3.6

跳转安装Tensorflow

(4)激活tensorflow的环境:

​ activate tensorflow

(5)检测tensorflow环境添加到anaconda环境变量中。

​ conda info --envs

(6)退出tensorflow环境:

​ deactivate

注:Anaconda的官方开发文档:

https://docs.anaconda.com/anaconda/user-guide/getting-started

https://anaconda.org/

4、安装Tensorflow

(1)设置国内代理:

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

​ conda config --set show_channel_urls yes

(2)更新pip:

​ python -m pip --default-timeout=100 install --upgrade pip

注:设大失效时间

(3)安装Tensorflow:

​ conda create -n tensorflow python=3.6

​ pip --default-timeout=100 install --upgrade --ignore-installed tensorflow

激活Tensorflow

(4)测试代码:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')  
sess = tf.Session()  
print(sess.run(hello)) 

注:国内源

新版ubuntu要求使用https源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

豆瓣:http://pypi.douban.com/simple/

设置pip安装从国内镜像获取:

(1)临时使用:pip install -i 地址

(2)永久设置:

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值