How do I list all currently available GPUs with pytorch?

蓝咒 提交于 2021-01-01 09:07:29

问题


I know I can access the current GPU using torch.cuda.current_device(), but how can I get a list of all the currently available GPUs?


回答1:


You can list all the available GPUs by doing:

>>> import torch
>>> available_gpus = [torch.cuda.device(i) for i in range(torch.cuda.device_count())]
>>> available_gpus
[<torch.cuda.device object at 0x7f2585882b50>]


来源:https://stackoverflow.com/questions/64776822/how-do-i-list-all-currently-available-gpus-with-pytorch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!