gpt4 book ai didi

Pytorch 找不到 CUDA 设备

转载 作者:行者123 更新时间:2023-12-04 12:58:38 25 4
gpt4 key购买 nike

我尝试在我的设置中使用 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/)

关于Pytorch 找不到 CUDA 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62407851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com