查看 PyTorch 是否使用 GPU
借助 torch.cuda 中的命令,可以帮助我们查看 PyTorch 是否使用 GPU。

当前设备索引
Pythontorch.cuda.current_device()

可用的 GPU 数量
Pythontorch.cuda.device_count()

GPU 设备名字,设备索引默认从 0 开始
Pythontorch.cuda.get_device_name(0)

检查 CUDA 是否可用
Pythontorch.cuda.is_available()
