gpt4 book ai didi

python - CUDA 初始化 : CUDA unknown error - this may be due to an incorrectly set up environment

转载 作者:行者123 更新时间:2023-12-04 11:33:24 26 4
gpt4 key购买 nike

我正在尝试安装具有 CUDA 支持的手电筒。
这是我的 collect_env.py 的结果脚本:

PyTorch version: 1.7.1+cu101
Is debug build: False
CUDA used to build PyTorch: 10.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.1 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: Could not collect

Python version: 3.9 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: 10.1.243
GPU models and configuration: GPU 0: GeForce GTX 1080
Nvidia driver version: 460.39
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] torch==1.7.1+cu101
[pip3] torchaudio==0.7.2
[pip3] torchvision==0.8.2+cu101
[conda] blas 1.0 mkl
[conda] cudatoolkit 10.1.243 h6bb024c_0
[conda] mkl 2020.2 256
[conda] mkl-service 2.3.0 py39he8ac12f_0
[conda] mkl_fft 1.3.0 py39h54f3939_0
[conda] mkl_random 1.0.2 py39h63df603_0
[conda] numpy 1.19.2 py39h89c1606_0
[conda] numpy-base 1.19.2 py39h2ae0177_0
[conda] torch 1.7.1+cu101 pypi_0 pypi
[conda] torchaudio 0.7.2 pypi_0 pypi
[conda] torchvision 0.8.2+cu101 pypi_0 pypi

Process finished with exit code 0
这是 nvcc - V 的输出
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
最后,这里是 nvidia-smi 的输出
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.39 Driver Version: 460.39 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 1080 Off | 00000000:01:00.0 On | N/A |
| 0% 52C P0 46W / 180W | 624MiB / 8116MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 873 G /usr/lib/xorg/Xorg 101MiB |
| 0 N/A N/A 1407 G /usr/lib/xorg/Xorg 419MiB |
| 0 N/A N/A 2029 G ...AAAAAAAAA= --shared-files 90MiB |
+-----------------------------------------------------------------------------+
但是,当我尝试运行时
print(torch.cuda.is_available())
我收到以下错误:
UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
return torch._C._cuda_getDeviceCount() > 0
我执行了重新启动,并按照 here 中详述的安装后步骤进行了操作。

最佳答案

您的安装非常适合 CUDA 和 nvidia 驱动程序,但问题在于您的 PyTorch 和 CUDA 版本,您至少需要 CUDA 10.2 才能获得支持 python 3.9 的最新版火炬
如果您使用 conda 只是创建一个新环境,则 conda 会处理 cuda 工具包,pip 和 conda 不能很好地配合使用:

pip uninstall uninstall torch torchaudio torchvision
创建新的 conda 环境
conda create --name yourenv python=3.9
conda activate yourenv
对于 CUDA 11.1:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
对于 CUDA 10.2:
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch -c conda-forge
如果您使用的是 pip 而不是 anaconda 环境
请引用 Pytorch Installation Docs / Requirements
最新版 Torch 原生仅支持 CUDA 10.2 和 11.1
尝试安装 CUDA 10.2 或 11.1
尝试升级您的 pip 并重新安装火炬:
使用卸载当前安装的 Torch 版本
pip uninstall torch torchaudio torchvision
升级点:
pip3 install --upgrade pip
安装 PyTorch:
pip install torch torchvision torchaudio  //cuda 10.2
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html //cuda 11.1

关于python - CUDA 初始化 : CUDA unknown error - this may be due to an incorrectly set up environment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66857471/

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