如何列出所有pytorch能用的GPU?pytorch查看GPU列表
Song • 6141 次浏览 • 0 个回复 • 2020年11月27日

你可以使用下面的方法列举出来可用的GPU列表:
>>> import torch
>>> available_gpus = [torch.cuda.device(i) for i in range(torch.cuda.device_count())]
>>> available_gpus
[<torch.cuda.device object at 0x7f2585882b50>]
# 获取可用数量
print(torch.cuda.device_count())
原创文章,转载请注明 :如何列出所有pytorch能用的GPU?pytorch查看GPU列表 - pytorch中文网
原文出处: https://ptorch.com/news/256.html
问题交流群 :168117787
- 没有评论