pytorch - Pytorch 找不到 CUDA 设备
问题描述
我尝试在我的设置中使用 Pytorch 中的 Cuda,但无法检测到它,我不知道为什么。
torch.cuda.is_available()
返回False
。深层发掘,
torch._C._cuda_getDeviceCount()
返回 0。使用 1.5 版,例如
$ pip freeze | grep torch
torch==1.5.0
我试图编写一个小的 C 程序来做同样的事情,例如
#include <stdio.h>
#include <cuda_runtime_api.h>
int main() {
int count = 0;
cudaGetDeviceCount(&count);
printf("Device count: %d\n", count);
return 0;
}
打印 1,因此 Cuda 运行时显然可以找到设备。另外,运行nvidia-smi
:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21 Driver Version: 435.21 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 106... Off | 00000000:02:00.0 On | N/A |
| 0% 41C P8 9W / 200W | 219MiB / 6075MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
那么我的 Cuda 设备在 Python 中消失在哪里了?
解决方案
我现在才意识到,如果 Pytorch 对于每个不同的 CUDA 次要版本都有不同的版本,所以在我的情况下,版本torch==1.5.0
显然默认为 CUDA 10.2,而特殊包torch==1.5.0+cu101
可以工作。
我希望这可以让其他喜欢我的人开始阅读 PyPi 上的文档(如果您知道在哪里可以查看更多最新文档:https ://pytorch.org/get-started/locally/ )
推荐阅读
- python-3.x - 为什么我的 Python 项目中出现 TypeError 异常?
- graph - gremlin 查询中的多个 if else
- java - 在当前活动上单击按钮(不是后退按钮)时关闭当前和上一个活动
- node.js - 将 expressjs 与 esbuild 捆绑会导致缺少 view.js 警告
- java - 为什么在考虑较低级别的实现时阻塞 get() 太慢并且异步方法链接不是?
- html - 如何更改活动切换的书写颜色
- python - 在数据库中保存表单数据
- python - 获取带有特定文本的标签旁边的文本
- java - Android动作模式和上下移动项目
- php - 我找不到此 php 错误的解决方案 解析错误:语法错误、意外的 ' ' (T_STRING)、期望函数 (T_FUNCTION) 或 const (T_CONST)?