请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册
查看: 4821|回复: 10

pytorch获取当前GPU信息

[复制链接]

84

主题

115

帖子

731

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
1467
发表于 2020-5-17 18:25:10 | 显示全部楼层 |阅读模式

pytorch获取当前GPU信息:
  1. import torch
  2. gpu_num = torch.cuda.device_count()
  3. print('GPU数量:%d' % (gpu_num))
  4. for i in range(gpu_num):
  5.     gpu_name = torch.cuda.get_device_name(i)
  6.     print('GPU名称:%s' % (gpu_name))
  7.     gpu_busy = torch.cuda.is_available()
  8.     print('%s是否可用:%d' % (gpu_name, gpu_busy))
  9.     gpu_index = torch.cuda.current_device()
  10.     print('当前GPU索引:%d' % (gpu_index))
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-19 08:32 , Processed in 0.249362 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表