先给大家看一下我成功安装的过程
其中最关键的就是授权,因为是权限不够,所以安装失败,被拒绝安装
这是错误信息:
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while installing package 'pytorch::cuda90-1.0-h6433d27_0'.
PermissionError(13, 'Permission denied')
Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Permission denied')
AssertionError()
授权:
sudo chown -R tdx:tdx /home/tdx/anaconda3
tdx是我用户名
然后继续安装pytorch即可成功。
验证是否安装成功
查看pytorch是否安装成功:
import torch
print("Support CUDA ?: ", torch.cuda.is_available())
x = torch.Tensor([1.0])
xx = x.cuda()
print(xx)
y = torch.randn(2, 3)
yy = y.cuda()
print(yy)
zz = xx + yy
print(zz)
# CUDNN TEST
from torch.backends import cudnn
print("Support cudnn ?: ",cudnn.is_acceptable(xx))
如果输出下面的内容表示成功!
Support CUDA ?: True
tensor([1.], device='cuda:0')
tensor([[-0.3443, 1.8490, -0.6681],
[-0.6760, -1.6212, -2.2254]], device='cuda:0')
tensor([[ 0.6557, 2.8490, 0.3319],
[ 0.3240, -0.6212, -1.2254]], device='cuda:0')
Support cudnn ?: True