Pytorch:torch,torchvision,cudatoolkit 对应的版本
https://pytorch.org/get-started/previous-versions/
下载torch以及torchvision,toolkit网址
http://download.pytorch.org/whl/torch_stable.html
下载下来的whl文件
在这个目录下
pip install xxxxxx.whl
在GPU上执行程序
a.自定义的参数需要转化为cuda支持的tensor
b.model需要转化为cuda支持的model
c.执行的结果需要和cpu的tensor计算时
tensor.cpu()把cuda的tensor转化为cpu的tensor
#定义一个device对象
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
例:将model定义在cuda上
my_linear = MyLinear().to(device)