2019.9.18
安装时候仔细看安装说明,cuda、cudnn、系统的版本需要对应。
2019.01.01 更新
可以直接去官网看安装指令,里面也有一些旧版本的指令入口:https://pytorch.org/
2019.02.16 更新
网速问题的话,安装指令示意:https://blog.csdn.net/m0_37644085/article/details/87446922
#阿里云
eg:安装:
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com torch
eg:更新:
pip install --upgrade -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com torch
#清华
eg:更新
pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host https://pypi.tuna.tsinghua.edu.cn/ torch
eg:安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host https://pypi.tuna.tsinghua.edu.cn/ torch
一、查看版本
先查看 CUDA 版本:
cat /usr/local/cuda/version.txt
查看 CUDNN 版本:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
二、测试
在终端中按以下顺序运行命令:
python
在打开的python命令行中运行
import torch
print(torch.cuda.is_available())
不报错的话即代表安装成功。最好再测个cuda能不能用,返回True。
三、卸载Pytorch
1、使用conda卸载Pytorch
conda uninstall pytorch
conda uninstall libtorch
2、使用pip卸载Pytorch
pip uninstall torch