环境配置

18的nvcc —version显示的CUDA版本(10.0)和nvidia-smi版本(12.4)不一样

conda create -n sas_det python=3.8
conda activate sas_det
conda install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.3 -c pytorch
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
git clone https://github.com/facebookresearch/detectron2.git
conda install ninja

python -m pip install -e detectron2 # 没法改cpp_extension.py来跳过CUDA版本检查(因为代码在/tmp下),采用下面的

cd detectron2
python setup.py build --force develop

报错:

File "/tmp/pip-build-env-xsd6d80w/overlay/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 413, in _check_cuda_version
raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
RuntimeError:
The detected CUDA version (10.0) mismatches the version that was used to compile
PyTorch (12.1). Please make sure to use the same CUDA versions.

detection2中添加pyproject.toml文件,内容如下:

[build-system]
requires = ["setuptools>=64", "torch"]
build-backend = "setuptools.build_meta"

如果你使用的是像pip这样的包管理器,可以使用 pip cache purge 清理缓存。

pip cache purge

编译问题https://blog.51cto.com/u_15353042/3752099

配置文件修改https://developer.aliyun.com/article/1626064

跳过CUDA版本检查https://blog.csdn.net/m0_51516317/article/details/139423784

报错:

In file included from /usr/local/cuda-10.0/include/cuda_runtime.h:83,
from <command-line>:
/usr/local/cuda-10.0/include/crt/host_config.h:129:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!
129 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!
| ^~~~~
error: command '/usr/local/cuda-10.0/bin/nvcc' failed with exit code 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10

可以使用 update-alternatives --config g++update-alternatives --config gcc 来查看和选择你想要使用的 g++gcc 版本

sudo yum update
sudo yum install gcc-7 g++-7


Author: CuberSugar
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source CuberSugar !
  TOC