tex*_*cii 9 windows gpu pytorch
我有pytorch脚本。
import torch
torch.cuda.is_available()
# True
device=torch.device('cuda:0')
# I moved my tensors to device
Run Code Online (Sandbox Code Playgroud)
但是当 pytorch 脚本运行时,Windows 任务管理器显示 GPU (NVIDIA GTX 1050TI) 使用率为零,我的脚本速度很好,如果我将 torch.device 更改为 CPU 而不是 GPU,速度会变慢,因此 cuda (GPU) 正在工作。为什么 Windows 任务管理器不显示 GPU 使用情况?
我的代码示例:
device=torch.device("cuda:0")
model=torch.load('mymodel.pth', map_location=torch.device(device))
image=Image.open('picture.png').convert('RGB')
transform=transforms.Compose([
transforms.Resize(224),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
input=transform(image)
input=torch.unsqueeze(input, 0)
input=input.to(device)
output=model(input)
Run Code Online (Sandbox Code Playgroud)
小智 9
Windows 任务管理器总体利用率似乎不包括 cuda 使用情况。确保选择图表中的 cuda 选项。
有关详细信息,请参阅:https://medium.com/@michaelceber/gpu-monitoring-on-windows-10-for-machine-learning-cuda-41088de86d65