`torch.cuda.is_available()` 返回 `False`,尽管已安装支持 CUDA 的 PyTorch。

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

torch.cuda.is_available() returns false despite installing pytorch with CUDA

问题

运行nvidia-smi命令会显示如下信息:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 528.33       驱动程序版本: 528.33       CUDA 版本: 12.0         |
|-------------------------------+----------------------+----------------------+
| GPU  名称           TCC/WDDM | 总线 ID        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         内存使用      | GPU-Util  计算 M.   |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  在 |                  无   |
| 无    49摄氏度 P8    无 /  无  |    244MiB /  4096MiB |      0%      默认    |
|                               |                      |                  无   |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| 进程:                                                                        |
|  GPU   GI   CI        PID   类型   进程名称                    GPU 内存       |
|        ID   ID                                                   使用        |
|=============================================================================|
+-----------------------------------------------------------------------------+

运行conda list pytorch命令显示:

# Name                    Version                   Build  Channel
pytorch                   1.13.1              py3.9_cpu_0    pytorch
pytorch-cuda              11.7                 h67b0de4_1    pytorch
pytorch-mutex             1.0                         cpu    pytorch

运行nvcc --version命令显示:

nvcc: NVIDIA (R) Cuda 编译器驱动程序
版权所有 (c) 2005-2022 NVIDIA Corporation
构建于 2022 年 6 月 8 日星期三 16:59:34 太平洋夏令时间
Cuda 编译工具,版本 11.7,V11.7.99
构建 cuda_11.7.r11.7/compiler.31442593_0

参考信息:我使用的是 GeForce GTX 1050ti。已尝试使用以下命令卸载和重新安装 pytorch:

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
英文:

running nvidia-smi gives,

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 528.33       Driver Version: 528.33       CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
| N/A   49C    P8    N/A /  N/A |    244MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

running conda list pytorch gives,

# Name                    Version                   Build  Channel
pytorch                   1.13.1              py3.9_cpu_0    pytorch
pytorch-cuda              11.7                 h67b0de4_1    pytorch
pytorch-mutex             1.0                         cpu    pytorch

running nvcc --version gives,

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:59:34_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0

For reference I have a GeForce GTX 1050ti

I've already tried uninstalling pytorch with conda and pip and reinstalling using,

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

答案1

得分: 2

我删除了所有与 torch 和 cuda 相关的内容(使用 conda list torch 和 conda list cuda 找到),然后重新安装了:

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

以及

conda install -c anaconda cudatoolkit

现在可以正常工作。

英文:

So I deleted everything torch related and cuda related (found using conda list torch and conda list cuda) then reinstalled using

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

and

conda install -c anaconda cudatoolkit

and it's working now

huangapple
  • 本文由 发表于 2023年2月27日 07:56:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75575757.html
匿名

发表评论

匿名网友

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

确定