open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.26k stars 2.62k forks source link

Cannot use the Mask2Former configs due to different of mmcv versions in mmdet and mmseg #3763

Open SHAMIK-97 opened 2 months ago

SHAMIK-97 commented 2 months ago

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug mmcv in mmdet use ver==2.2.0 but mmseg uses ver<=2.2.0

Reproduction

  1. What command or script did you run?

!pip install -U openmim !mim install mmengine !mim install "mmcv>=2.0.0" !pip install cityscapesscripts !pip install ftfy !mim install "mmdet"

!git clone https://github.com/open-mmlab/mmsegmentation.git %cd mmsegmentation !git checkout main !pip install -e .

import mmseg from mmseg.apis import inference_model, init_model, show_result_pyplot import mmcv print(mmseg.version)


2. Did you make any modifications on the code or config? Did you understand what you have modified?
yes

In mmseg changed---> __init__.py
assert (mmcv_min_version <= mmcv_version)

removed the assertion mmcv_max_version

3. What dataset did you use?

**Environment**

sys.platform: linux
Python: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: Tesla T4
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.2, V12.2.140
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.4.0+cu121
PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201703
  - Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v3.4.2 (Git Hash 1137e04ec0b5251ca2b4400a4fd3c667ce843d67)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 12.1
  - NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
  - CuDNN 90.1  (built against CUDA 12.4)
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.1, CUDNN_VERSION=9.1.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=2.4.0, USE_CUDA=ON, USE_CUDNN=ON, USE_CUSPARSELT=1, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF, 

TorchVision: 0.19.0+cu121
OpenCV: 4.10.0
MMEngine: 0.10.4
MMSegmentation: 1.2.2+b040e14

3. You may add addition that may be helpful for locating the problem, such as
   - How you installed PyTorch \[e.g., pip, conda, source\]
   - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)

**Error traceback**

/usr/local/lib/python3.10/dist-packages/mmengine/optim/optimizer/zero_optimizer.py:11: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import \
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-14-6dd1cac74e8f>](https://localhost:8080/#) in <cell line: 2>()
      1 import mmseg
----> 2 from mmseg.apis import inference_model, init_model, show_result_pyplot , inference_model_1
      3 import mmcv
      4 import cv2
      5 import glob

7 frames
[/usr/local/lib/python3.10/dist-packages/mmdet/__init__.py](https://localhost:8080/#) in <module>
     15 
     16 assert (mmcv_version >= digit_version(mmcv_minimum_version)
---> 17         and mmcv_version < digit_version(mmcv_maximum_version)), \
     18     f'MMCV=={mmcv.__version__} is used but incompatible. ' \
     19     f'Please install mmcv>={mmcv_minimum_version}, <{mmcv_maximum_version}.'

AssertionError: MMCV==2.2.0 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.2.0.

```none
A placeholder for trackback.

Bug fix

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

Ankit-4-code commented 1 month ago

I had the same problem when I was trying to follow their tutorial. I think the problem is with the pytorch version. Even I upgraded my pytorch to 2.4 and I got this version mismatch error.

What worked for me is that I downgraded my pytorch to 2.1.2 with cuda 12.1 and then it started working. Maybe you could try that and see if that helps.

JohnalDsouza commented 1 month ago

i just changed the version to 2.2.1 in mmdet/init.py worked for me :) mmcv_minimum_version = '2.0.0rc4' mmcv_maximum_version = '2.2.1' mmcv_version = digit_version(mmcv.version)