我是靠谱客的博主 拉长汽车,这篇文章主要介绍Win10下用Anaconda3安装TensorFlow和pytorch(python3.5),现在分享给大家,希望可以做个参考。

1、安装Anaconda3。

Anaconda默认Python3.6,由于TensorFlow需要Python3.5,因此需要在root环境下更改Python版本。

2、添加镜像源。

复制代码
1
2
3
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes

3、安装Python3.5。

复制代码
1
conda install python=3.5

等一会。

4、升级pip。直接用pip安装TensorFlow会出错。

使用管理员权限打开Anaconda Prompt

复制代码
1
pip install --upgrade pip

关闭Anaconda Prompt,重新打开。

5、安装tensorflow。(CPU版本)

复制代码
1
pip install --upgrade --ignore -installed tensorflow

6、测试tensorflow。

复制代码
1
spyder

在Spyder中输入:

复制代码
1
2
3
4
import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))

7、安装pytorch。

先安装

复制代码
1
conda install numpy mkl cffi

或者需要升级mkl库

复制代码
1
2
pip install mkl pip install mkl --upgrade

或者

复制代码
1
2
conda install mkl conda update mkl

如果想要更新所有库

复制代码
1
conda update --all

安装pytorch。(CPU版本)
链接: https://pan.baidu.com/s/10K8x6n2a51hKKD5sc3_9YA 密码: mn7r
下载 pytorch-cpu-0.3.1-py35_cpuhe774522_2.tar.bz2

复制代码
1
conda install --offline pytorch-cpu-0.3.1-py35_cpuhe774522_2.tar.bz2
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 测试 tensorflow 和 pytorch是否正常工作 import tensorflow as tf import torch from torch.backends import cudnn hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) x = torch.Tensor([1, 3]) y = torch.Tensor([2, 4]) z = x + y # z = z.cuda() # cpu版本没有cuda print(z) print(cudnn.is_acceptable(x))

最后

以上就是拉长汽车最近收集整理的关于Win10下用Anaconda3安装TensorFlow和pytorch(python3.5)的全部内容,更多相关Win10下用Anaconda3安装TensorFlow和pytorch(python3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部