Ubuntu/win安装Pytorch和Tensorflow
说明:
这两种框架的搭建,均基于Anaconda进行搭建。先在系统中安装Anaconda软件。
一、Pytorch的搭建
windows安装
(1)搭建参考官网给的命令,pytorch官网
(2)下载地址:https://download.pytorch.org/whl/torch_stable.html
从上述地址自行下载对应的版本(要求符合python的版本,cWuda 的版本信息)
比如我的CUDA是11.2 ,python是3.7版本,在Windows系统下
那么下载cu111/torch-1.8.1%2Bcu111-cp36-cp36m-win_amd64.whl
下载完成后,在cmd界面跳转到文件所在的目录下面,然后执行安装:
pip install cu111/torch-1.8.1%2Bcu111-cp36-cp36m-win_amd64.whl
Linux安装
(1)创建虚拟环境
(2)安装pytorch
我们改变策略 。记录好需要安装的包,直接用pip从豆瓣源下载。根据官方命令,我们需要安装的是torch1.8.1版本,torchvision0.9.1版本,torchaudio==0.8.1版本。
安装torch==1.8.1
pip install torch==1.8.1 -i https://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com
安装torchvision==0.9.1
pip install torchvision==0.9.1 -i https://pypi.douban.com/simple --trusted-host pypi.douban.com
安装torchaudio==0.8.1
pip install torchaudio==0.8.1 -i https://pypi.douban.com/simple --trusted-host pypi.douban.com
关于版本说明
torch
与torchvision
对应关系,来源:官方Repo: vision
torch | torchvision | python |
---|---|---|
main / nightly | main / nightly | >=3.8, <=3.10 |
2.0.0 | 0.15.1 | >=3.8, <=3.10 |
1.13.0 | 0.14.0 | >=3.7.2, <=3.10 |
1.12.0 | 0.13.0 | >=3.7, <=3.10 |
1.11.0 | 0.12.3 | >=3.7, <=3.10 |
1.10.2 | 0.11.3 | >=3.6, <=3.9 |
1.10.1 | 0.11.2 | >=3.6, <=3.9 |
1.10.0 | 0.11.1 | >=3.6, <=3.9 |
1.9.1 | 0.10.1 | >=3.6, <=3.9 |
1.9.0 | 0.10.0 | >=3.6, <=3.9 |
1.8.2 | 0.9.2 | >=3.6, <=3.9 |
1.8.1 | 0.9.1 | >=3.6, <=3.9 |
1.8.0 | 0.9.0 | >=3.6, <=3.9 |
1.7.1 | 0.8.2 | >=3.6, <=3.9 |
1.7.0 | 0.8.1 | >=3.6, <=3.8 |
1.7.0 |