1.Conda创建虚拟环境
conda create -n pytorch_gpu python=3.6
2.安装pytorch
2.1 Conda安装pytorch(下载安装慢,网络条件不好,下载依赖包经常中断)
conda install pytorch torchvision torchaudio cudatoolkit=11.0
2.2 Pip安装pytorch(下载安装相对较快,推荐)
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
3.测试pytorch安装成功
(pytorch_gpu) scnu-go@scnu-go:~$ python
Python 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 23:10:56)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
>>> True
Pytorch 官方 :https://pytorch.org/get-started