赞
踩
登录PyTorch官网(https://PyTorch.org/),登录后选择对应项
然后将
复制到命令行,进行安装。
安装之后启动python,执行如下命令,如果没有报错,说明安装成功。
查看GPU加速是否可用:
import torch
from torch import nn
print(torch.duda.is_available()) # true 查看GPU是否可用
print(torch.cuda.device_count()) #GPU数量, 1
torch.cuda.current_device() #当前GPU的索引, 0
torch.cuda.get_device_name(0) #输出GPU名称
Tensor的GPU计算:
x = torch.ten
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。