pytorch 查看GPU的数目和当前型号
2021-12-31 本文已影响0人
王叽叽的小心情
想要了解pytorch中的GPU参数如何设置,所以找到了如下代码,主要包括如下:
# 判断torch是否可用
torch.cuda.is_available()
# 查看GPU数量
torch.cuda.device_count()
# 查看GPU名字
torch.cuda.get_device_name(0)
# 查看当前设备索引
torch.cuda.current_device()
import torch
torch.cuda.is_available()
True
torch.cuda.device_count()
1
torch.cuda.get_device_name(0)
/home/wangyx/.conda/envs/gcn/lib/python3.7/site-packages/torch/cuda/init.py:104: UserWarning:
GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70 sm_75.
If you want to use the GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
'GeForce RTX 3090'
torch.cuda.current_device()
0