conda 中 cuda 和 pytorch 版本不匹配

问题描述 投票:0回答:1

在我的 conda

test
env 中,当我尝试通过
python setup.py install
安装第三方库时,出现如下错误:

File "/home/igs/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 387, in _check_cuda_version raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
RuntimeError: 
The detected CUDA version (10.1) mismatches the version that was used to compile PyTorch (11.7). Please make sure to use the same CUDA versions.

我在 conda

test
env 中检查如下并得到:

# check A
$ nvcc -V
...
Cuda compilation tools, release 10.1, V10.1.243
# check B
$ nvidia-smi
...
CUDA Version: 12.1 
# check C
$ python3 -c "import torch; print(torch.__version__)"
2.0.1+cu117
# check D
$ conda list | sed -n "3p" && conda list | grep -i -E "cuda|torch"
# Name                    Version                   Build  Channel
cudatoolkit               10.2.89              hfd86e86_1    defaults
ffmpeg                    4.3                  hf484d3e_0    pytorch
pytorch                   1.9.1           py3.8_cuda10.2_cudnn7.6.5_0    pytorch
torchaudio                0.9.1                      py38    pytorch
torchvision               0.10.1               py38_cu102    pytorch

据我了解,

check B
是可以的,
check A
check D
匹配,但是
check C
不匹配,看起来它使用了另一个版本
torch/pytorch
。为什么会发生这种情况以及如何克服它?感谢您的任何建议。

附注在这个conda

test
环境中,我根据
offcial
安装了pytorch

conda install pytorch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1 cudatoolkit=10.2 -c pytorch

更新1

#check E
$ pip list | grep -i -E "cuda|torch"
nvidia-cuda-cupti-cu11               11.7.101
nvidia-cuda-nvrtc-cu11               11.7.99
nvidia-cuda-runtime-cu11             11.7.99
torch                                2.0.1
torchvision                          0.15.2
python pytorch conda
1个回答
0
投票

在conda

export PYTHONNOUSERSITE=True
env 中的
test
之后,看起来问题已经解决了。

参考: https://github.com/conda/conda/issues/7707

© www.soinside.com 2019 - 2024. All rights reserved.