一、下载 pytorch
pytorch官网:https://pytorch.org/get-started/locally/
选择对应的版本
nvidia-smi
conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
(删掉-c pytorch使用清华源)
或者:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
二、验证是否配置成功
python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.12.1+cu116
>>> print(torch.version.cuda)
11.6
>>> print(torch.cuda.is_available())
True
# 查看虚拟环境的包
conda list