您当前的位置: 首页 >  pytorch
  • 1浏览

    0关注

    483博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Pytorch中检查cuda的信息

高精度计算机视觉 发布时间:2022-03-10 11:01:50 ,浏览量:1

Check CUDA version in PyTorch

gcptutorials.com PyTorch

This article explains how to check CUDA version, CUDA availability, number of available GPUs and other CUDA device related details in PyTorch. torch.cuda package in PyTorch provides several methods to get details on CUDA devices.

PyTorch Installation

For following code snippet in this article PyTorch needs to be installed in your system. If you don't have PyTorch installed, refer How to install PyTorch for installation.

Check CUDA availability in PyTorch

   
import torch

print(torch.cuda.is_available())
 

Check CUDA version in PyTorch

   
print(torch.version.cuda)
 

Get number of available GPUs in PyTorch

   
print(torch.cuda.device_count())
 

Get properties of CUDA device in PyTorch

   
print(torch.cuda.get_device_properties("cuda:0"))
 

In case you more than one GPUs than you can check their properties by changing "cuda:0" to "cuda:1'"cuda:2" and so on.

Get CUDA device name in PyTorch

   
print(torch.cuda.get_device_name("cuda:0"))
 

In case you more than one GPUs than you can check their names by changing "cuda:0" to "cuda:1'"cuda:2" and so on.

关注
打赏
1661664439
查看更多评论
立即登录/注册

微信扫码登录

0.0372s