Pytorch:info about your GPU

import torch
print(torch.cuda.is_available())		 # 查看GPu设备是否可用
print(torch.cuda.device_count()) 		# 查看GPu设备数量
print(torch.cuda.get_device_name())   	# 查看当前GPu设备名称,默认设备id从0开始
print(torch.cuda.current_device())		# 查看当前GPu设备id

True
1
NVIDIA GeForce RTX 3090
0

torch.cuda.is_available() #查看显卡是否能用
import torch
torch.cuda.set_device(0)#通过id设置显卡    

猜你喜欢

转载自blog.csdn.net/weixin_43332715/article/details/125032028
今日推荐