exit code: 1 ╰─> [120 lines of output] /media/aaeon/62A6D153A6D12875/jetson/mmcv-2.0.0rc4/setup.py:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import DistributionNotFound, get_distribution A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/aaeon/62A6D153A6D12875/jetson/mmcv-2.0.0rc4/setup.py", line 10, in <module> import torch File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/__init__.py", line 1382, in <module> from .functional import * # noqa: F403 File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/functional.py", line 7, in <module> import torch.nn.functional as F File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), /home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /tmp/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), /home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: Apache Software License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running develop /home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/command/develop.py:41: EasyInstallDeprecationWarning: easy_install command is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` and ``easy_install``. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://github.com/pypa/setuptools/issues/917 for details. ******************************************************************************** !! easy_install.initialize_options(self) /home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:90: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() running egg_info writing mmcv.egg-info/PKG-INFO writing dependency_links to mmcv.egg-info/dependency_links.txt writing requirements to mmcv.egg-info/requires.txt writing top-level names to mmcv.egg-info/top_level.txt /home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/utils/cpp_extension.py:502: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend. warnings.warn(msg.format('we could not find ninja.')) reading manifest file 'mmcv.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' adding license file 'LICENSES.md' writing manifest file 'mmcv.egg-info/SOURCES.txt' running build_ext Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/aaeon/62A6D153A6D12875/jetson/mmcv-2.0.0rc4/setup.py", line 315, in <module> setup( File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands self.run_command(cmd) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/command/develop.py", line 35, in run self.install_for_development() File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/command/develop.py", line 112, in install_for_development self.run_command('build_ext') File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 525, in build_extensions _check_cuda_version(compiler_name, compiler_version) File "/home/aaeon/anaconda3/envs/py3.10/lib/python3.10/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 (11.6) mismatches the version that was used to compile PyTorch (12.2). Please make sure to use the same CUDA versions. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip.
时间: 2025-07-01 13:57:32 浏览: 19
### 安装 mmcv 时出现 CUDA 版本不匹配错误的解决方法
在安装 `mmcv` 时遇到如下报错信息:
```
RuntimeError: The detected CUDA version (11.6) mismatches the version that was used to compile PyTorch (12.2)
```
该问题的根本原因在于当前环境中 PyTorch 所编译使用的 CUDA Toolkit 版本与系统中检测到的 CUDA 驱动版本不一致。PyTorch 的构建版本通常绑定特定的 CUDA 工具包版本,若环境中存在多个 CUDA 版本或未正确配置运行时路径,可能导致此类冲突。
---
### 解决方案一:使用 Conda 管理 CUDA 版本并隔离环境
推荐使用 Conda 创建独立虚拟环境,并通过 Conda 安装与 PyTorch 版本兼容的 CUDA 工具包。例如,若 PyTorch 编译使用的是 CUDA 11.3,则可执行以下命令:
```bash
conda create -n mmcv_env python=3.8
conda activate mmcv_env
conda install pytorch==1.10.1 torchvision==0.11.1 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch
```
Conda 会自动下载并管理对应的 CUDA 工具包版本,避免与系统全局 CUDA 版本冲突。这种方式适用于大多数开发场景,尤其是需要多版本共存时[^2]。
---
### 解决方案二:安装与当前 CUDA 驱动兼容的 PyTorch 预编译版本
若希望保留当前环境中的 CUDA 驱动(如 11.6),应选择与之兼容的 PyTorch 构建版本。可通过 [PyTorch 官方网站](https://pytorch.org/get-started/locally/) 获取对应 CUDA 版本的安装命令。例如,安装支持 CUDA 11.6 的 PyTorch:
```bash
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
```
此方式适用于系统驱动已固定且无法降级的情况,确保 PyTorch 使用的 CUDA 版本与运行时检测一致[^1]。
---
### 解决方案三:通过软链接或 LD_LIBRARY_PATH 调整动态库加载路径
如果确认系统中已安装所需版本的 CUDA 工具包,但运行时报错仍检测到其他版本,可以通过设置 `LD_LIBRARY_PATH` 强制指定查找路径:
```bash
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH
```
或者,在系统路径下建立指向目标 CUDA 版本的软链接:
```bash
sudo ln -sf /usr/local/cuda-11.3 /usr/local/cuda
```
随后更新动态链接器缓存以确保生效:
```bash
sudo ldconfig
```
该方法适用于系统管理员或高级用户,用于统一 CUDA 运行时环境[^3]。
---
### 安装 mmcv-full 并指定 CUDA 版本
若需安装支持 CUDA 的完整版 `mmcv`(即 `mmcv-full`),建议在上述环境配置完成后执行:
```bash
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/index.html
```
安装程序将自动匹配当前 PyTorch 和 CUDA 的版本进行构建,避免版本冲突导致的运行时错误[^4]。
---
阅读全文
相关推荐



















