获取PyTorch中GPU的CUDA计算能力如何?

huangapple go评论63阅读模式
英文:

How to get CUDA compute capability of a GPU in Pytorch?

问题

这个问题非常简单:我的一个用户在使用PyTorch时遇到了一个错误:

找到了GPU0 NVIDIA GeForce GT 710,其CUDA能力为3.5。
PyTorch不再支持这个过于老旧的GPU。
此库支持的最低CUDA能力为3.7。

这意味着我不能仅仅依赖于torch.cuda.is_available()来检查它是否能够运行我的代码。我还需要确保GPU的CUDA计算能力是否大于或等于3.7。然而,出于某种奇怪的原因,似乎在Stack Overflow或Google上找不到获取GPU的CUDA计算能力的看似简单任务,尽管在错误消息中似乎可以轻松获取它。

英文:

The question is very simple: One of my users encountered an error in pytorch:

Found GPU0 NVIDIA GeForce GT 710 which is of cuda capability 3.5.
PyTorch no longer supports this GPU because it is too old.
The minimum cuda capability supported by this library is 3.7.

This means I cannot rely on torch.cuda.is_available() to check whether it can actually run my code. I need to also make sure the CUDA compute capability of the GPU is >= 3.7. Yet, for some strange reason, the seemingly simple task of getting a GPU's CUDA compute capability is nowhere to be found on stack overflow or Google, despite that right there in the error message it seems to get it no problem.

答案1

得分: 3

我没有意识到的是torch.cuda.get_device_properties(0)的“major”和“minor”实际上是CUDA计算能力。例如,如果major是7,minor是5,CUDA计算能力为7.5。也可以通过get_device_capability来完成。

英文:

What I did not realize is that the "major" and "minor" of torch.cuda.get_device_properties(0) is actually the CUDA compute capability. For example, if major is 7 and minor is 5, cuda capability is 7.5. It can also be done via get_device_capability.

huangapple
  • 本文由 发表于 2023年2月24日 13:14:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75552834.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定