open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.91k stars 1.65k forks source link

[Bug] Compatibility issues with installation of mmcv #3168

Closed Liumucan closed 3 months ago

Liumucan commented 3 months ago

Prerequisite

Environment

PyTorch==2.4.0+cu124 MMCV==2.2.0

Reproduces the problem - code sample

I'm facing a problem with the installation of mmcv on my system. I'm trying to run a project that requires an older version of mmcv (1.3.18), but when I install this version, I will meet the incompatible like follows: AssertionError: MMCV==1.3.16 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.1.0. Then, I follow this instruction to install higher version mmcv (i.e., 2.0.0rc4). However, there is a issue that the project code are significantly different between the older and newer versions of mmcv. Many of the modules that were previously imported from mmcv are now either removed or moved to a different location, causing compatibility issues. I've tried to find information on how to import these modules from the newer version of mmcv, but I've only found details on how to import some modules from mmengine. However, there are still many modules that I'm unable to import. The following are the modules I'd like to import:

import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint,
                         wrap_fp16_model)
from mmdet.datasets import (build_dataloader, build_dataset,
                            replace_ImageToTensor)
from mmdet.models import build_detector

There seems to be no comprehensive document to introduce how we can use these modules in the new version of mmcv. Could you please provide suggestions about how should I deal with this problem?

Reproduces the problem - command or script

import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint,
                         wrap_fp16_model)
from mmdet.datasets import (build_dataloader, build_dataset,
                            replace_ImageToTensor)
from mmdet.models import build_detector

Reproduces the problem - error message

Traceback (most recent call last):
  File "test.py", line 27, in <module>
    from mmcv import Config, DictAction
ImportError: cannot import name 'Config' from 'mmcv' (/home/user10/.conda/envs/fashion_former2/lib/python3.8/site-packages/mmcv/__init__.py)

Additional information

No response

Liumucan commented 3 months ago

I have changed the CUDA version to meet the requirement of the lower version mmcv.

tianlianghai commented 6 days ago

same here, the mmcv.runner._load_checkpoint is removed since runner is removed, however the mmengine.runner.load_checkpoint doesn't has the same functionality as the mmcv one. It just drive me crazy when two repo use different version of mmlab modules and you have to combine them together. the backward-compatibility is .... suck.