Skip to content

Dependency Conflict: PyTorch 2.0 requires mmcv-full>=1.7.2, but mmdet3d requires mmcv-full<1.7.2 #258

Open

Description

@PureKoala

I am attempting to set up the UniAD environment using PyTorch 2.0.1 and CUDA 11.8 just as installation document. I have encountered a circular dependency issue regarding mmcv-full and mmdet3d.

Current Environment:

  • Python: 3.9
  • PyTorch: 2.0.1
  • CUDA: 11.8

The Problem:

There is a conflict between the requirements for PyTorch 2.0 and the requirements for mmdet3d==1.0.0rc6 (which is required by UniAD).

  1. Scenario A (Follow UniAD requirements):
    I try to install mmcv-full==1.6.1 (as required by mmdet3d).
    Result: Since there are no pre-compiled wheels for mmcv-full 1.6.1 on PyTorch 2.0 + CUDA 11.8, the installation fails to build CUDA extensions.
    Error: ModuleNotFoundError: No module named 'mmcv._ext'

  2. Scenario B (Support PyTorch 2.0):
    I install mmcv-full==1.7.2 (compatible with PyTorch 2.0).
    Result: mmcv._ext loads correctly, but mmdet3d crashes because it strictly asserts mmcv_full < 1.7.0.
    Error: Version incompatibility assertion in mmdet3d.

Is there a recommended workaround to run UniAD with PyTorch 2.0? Or is strict downgrade to PyTorch 1.12.x the only supported path currently?

Activity

  1. kmsngh commented on Nov 25, 2025

    @kmsngh

    I built mmcv-full==1.6.0 from source with pytorch 2. It worked

  2. OuchDanny commented on Nov 25, 2025

    @OuchDanny

    Key cause: pip uses an isolated build environment by default, so the build process cannot see the torch and cuda installed in your environment. Use --no-build-isolation to force building in the current env and set MMCV_WITH_OPS=1 to force ops compilation.

    Prerequisites

    • PyTorch installed and matched to CUDA (e.g., torch 2.0.1+cu118).
    • System CUDA toolkit with nvcc installed (e.g., CUDA 11.8).
    • Use python -m pip to ensure pip runs in the active environment.

    Install steps

    # Set CUDA (adjust path if needed)
    export CUDA_HOME=/usr/local/cuda-11.8
    export PATH=$CUDA_HOME/bin:$PATH
    
    # Uninstall existing mmcv packages
    python -m pip uninstall -y mmcv mmcv-full
    
    # Build in current env with ops enabled (disable build isolation)
    MMCV_WITH_OPS=1 python -m pip install --no-build-isolation --no-cache-dir mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0.0/index.html -v
    

    Verify

    python -c "import mmcv, importlib; importlib.import_module('mmcv._ext'); print('mmcv._ext ok')"
    


    原因:pip 默认使用隔离构建环境,导致构建时看不到你环境里的 torch和cuda。用 --no-build-isolation 强制在当前 env 构建,且设置 MMCV_WITH_OPS=1 强制编译 ops。

    1. 确认 nvcc 与 CUDA_HOME(你已有 nvcc 11.8并且有torch2.0.1):
    nvcc --version
    export CUDA_HOME=/usr/local/cuda-11.8   # 若系统 CUDA 路径不同请改为实际路径
    export PATH=$CUDA_HOME/bin:$PATH
    
    1. 卸载并从源码在当前 env 编译(注意:这会调用 nvcc/gcc,可能需要较长时间):
    python -m pip uninstall -y mmcv mmcv-full
    MMCV_WITH_OPS=1 python -m pip install --no-build-isolation --no-cache-dir mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0.0/index.html -v
    
    1. 验证:
    python -c "import mmcv, importlib; importlib.import_module('mmcv._ext'); print('mmcv._ext ok')"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions