Anaconda+Python3+Pytorch环境配置

Anaconda + Python3 + Pytorch环境配置

Anaconda,Python, Pytorch

1.Anacoda 的安装

从Anaconda 的官方网站
https://www.anaconda.com/ 上下载最新的安装包:
但是这样下载特别特别慢

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

这里提供一种快速的下载方式 从清华大学的开源软件镜像站下载,链接:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
有一点非常重要,下载的路径不要有空格,全英文

2.Python 3.6 的安装

在Anaconda Prompt输入conda install python=3.6,进行降版

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

3.Anaconda3的spyder测试

查看Anaconda3 文件夹,打开spyder编辑,输入代码进行测试 代码如下:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_surface(X, Y, Z, rstride=8,
cstride=8, alpha=0.3) cset = ax.contour(X, Y, Z, zdir='z',
offset=-100, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='x',
offset=-40, cmap=cm.coolwarm) cset = ax.contour(X, Y, Z, zdir='y',
offset=40, cmap=cm.coolwarm)
ax.set_xlabel('X') ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z') ax.set_zlim(-100, 100)
plt.show()

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

4.Pytorch 的安装

打开Anaconda Prompt, 输入命令来添加镜像文件,提高下载速度。

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
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

conda install pytorch-cpu

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

conda install pytorch

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

conda install pytorch cuda90

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

conda install pytorch cuda91

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

torchvision可以通过cmd安装你,输入pip install torchvision

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

最后测试pytorch是否安装成功

《Anaconda+Python3+Pytorch环境配置》
《Anaconda+Python3+Pytorch环境配置》

    原文作者:只猫·影逝二度
    原文地址: https://zhuanlan.zhihu.com/p/64624579
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞