0%

The detected CUDA version (x.x) mismatches the version that was used to compile PyTorch (x.x).

今天在安装某个库的时候报错

1
2
3
4
5
$ pip install -e .
(一些无关紧要的输出)
The detected CUDA version (10.2) mismatches the version that was used to compile
PyTorch (11.7). Please make sure to use the same CUDA versions.
(还是一些无关紧要的输出)

但是我是用conda配置的环境,而且11.7的cudatoolkit和cudatoolkit-dev都已经安装了

由于我的pytorch是用 Previous PyTorch Versions 给出的pip指令重新安装的对应cuda版本的torch,所以编译torch的cuda版本也是11.7

1
2
$ python -c "import torch; print(torch.__version__)"
1.13.1+cu117

也就是说问题出在pip忽略掉了目前conda环境内的cuda版本,从别的地方随便找了个cuda

遂google, 发现解决方案如下:

1
pip install --no-build-isolation -e .

成功安装

Welcome to my other publishing channels