一、报错:
/home/XXX/miniconda3/envs/dinov2/lib/python3.9/site-packages/torch/utils/cpp_extension.py:398: UserWarning: There are no g++ version bounds defined for CUDA version 11.8
warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
building 'mmcv._ext' extension
creating build/temp.linux-x86_64-cpython-39
creating build/temp.linux-x86_64-cpython-39/mmcv
creating build/temp.linux-x86_64-cpython-39/mmcv/ops
creating build/temp.linux-x86_64-cpython-39/mmcv/ops/csrc
creating build/temp.linux-x86_64-cpython-39/mmcv/ops/csrc/pytorch
creating build/temp.linux-x86_64-cpython-39/mmcv/ops/csrc/pytorch/cpu
creating build/temp.linux-x86_64-cpython-39/mmcv/ops/csrc/pytorch/cuda
gcc -pthread -B /home/XXX/miniconda3/envs/dinov2/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/XXX/miniconda3/envs/dinov2/include -I/home/XXX/miniconda3/envs/dinov2/include -fPIC -O2 -isystem /home/XXX/miniconda3/envs/dinov2/include -fPIC -DMMCV_WITH_CUDA -I/tmp/pip-install-pve3nwsx/mmcv-full_8509d9f644eb4382946d87d9b0b48dc7/mmcv/ops/csrc/common -I/tmp/pip-install-pve3nwsx/mmcv-full_8509d9f644eb4382946d87d9b0b48dc7/mmcv/ops/csrc/common/cuda -I/home/XXX/miniconda3/envs/dinov2/lib/python3.9/site-packages/torch/include -I/home/XXX/miniconda3/envs/dinov2/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/XXX/miniconda3/envs/dinov2/lib/python3.9/site-packages/torch/include/TH -I/home/XXX/miniconda3/envs/dinov2/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/XXX/miniconda3/envs/dinov2/include/python3.9 -c ./mmcv/ops/csrc/pytorch/active_rotated_filter.cpp -o build/temp.linux-x86_64-cpython-39/./mmcv/ops/csrc/pytorch/active_rotated_filter.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0
<command-line>: fatal error: /usr/local/cuda/include/stdc-predef.h: Permission denied
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mmcv-full
Running setup.py clean for mmcv-full
Failed to build mmcv-full
ERROR: Could not build wheels for mmcv-full, which is required to install pyproject.toml-based projects
二、解决办法
把该路径加权限:
sudo chmod -R a+r /usr/local/cuda/include
或者
sudo chmod 777 -R /usr/local/cuda/include/
三、附带链接
torch版本选择:https://pytorch.org/get-started/previous-versions/
mmcv版本选择:https://mmcv.readthedocs.io/en/v1.5.0/get_started/installation.html