windows - 在 Windows 上使用带有 PyTorch 的 CUDA 时,GPU 使用率显示为零
问题描述
我有 pytorch 脚本。
import torch
torch.cuda.is_available()
# True
device=torch.device('cuda:0')
# I moved my tensors to device
但是,当 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)
解决方案
Windows 任务管理器的整体利用率似乎不包括 cuda 的使用。确保在图中选择 cuda 选项。
推荐阅读
- python - 将字符串转换为原始字符串并创建文件时出现操作系统错误
- python - 将嵌套的 Json 转换为 CSV Python
- javascript - JavaScript - getElementById 在特定页面上不起作用
- python - 在 Windows 中的 python 3.8 上安装 Django
- python - Python 中的退出代码 77 是什么意思?
- excel-formula - 如何在新的 Excel Calc 引擎中溢出部分单元格区域?
- c# - 带有 CollectionAssert.AreEquivalent() 的单元测试列表
- shell - 从文件的同一行中删除重复项
- php - 如何使用 bat 运行 php,使用 cron 作业运行 vbs 脚本
- php - 如何在 PHP 中使用这个 POST CURL