# Python 3.5
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
# Python 3.5
pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1.post2-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
正常情况应该输出类似如下结果:
tensor([[0.2710, 0.6443, 0.5779],
[0.4283, 0.1401, 0.1689],
[0.2173, 0.6645, 0.2762],
[0.5044, 0.9063, 0.4861],
[0.7070, 0.9941, 0.0107]])
import torch
if(torch.cuda.is_available()):
print("cuda is available")
else:
print("no cuda")