Repository: open-compass/opencompass
Issue: 使用官方脚本跑mini-gpt4评测时报错
Root cause: Environment Incompatibility

### Prerequisite

- [X] I have searched [Issues](https://github.com/InternLM/opencompass/issues/) and [Discussions](https://github.com/InternLM/opencompass/discussions) but cannot get the expected help.
- [X] The bug has not been fixed in the [latest version](https://github.com/InternLM/opencompass).

### Type

I'm evaluating with the officially supported tasks/models/datasets.

### Environment

torch                    2.0.1
mmengine                 0.8.4
mmpretrain               1.0.1


### Reproduces the problem - code/configuration sample

task配置如下：
from mmengine.config import read_base

with read_base():
    from .minigpt_4.minigpt_4_7b_mmbench import (minigpt_4_dataloader,
                                                 minigpt_4_evaluator,
                                                 minigpt_4_load_from,
                                                 minigpt_4_model)

models = [minigpt_4_model]
datasets = [minigpt_4_dataloader]
evaluators = [minigpt_4_evaluator]
load_froms = [minigpt_4_load_from]
num_gpus = 8
num_procs = 8
launcher = 'pytorch'


### Reproduces the problem - command or script

启动命令如下：
python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug

### Reproduces the problem - error message

报错信息如下：
nd will be removed in future. Use torchrun.
Note that --use-env is set by default in torchrun.
If your script expects `--local-rank` argument to be set, please
change it to read from `os.environ['LOCAL_RANK']` instead. See 
https://pytorch.org/docs/stable/distributed.html#launch-utility for 
further instructions

  warnings.warn(
/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments
  warnings.warn(
08/10 14:37:02 - OpenCompass - INFO - Partitioned into 1 tasks.
08/10 14:37:02 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults
08/10 14:37:03 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks
08/10 14:37:03 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass"
08/10 14:37:03 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer
08/10 14:37:03 - OpenCompass - INFO - Task minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults
08/10 14:37:03 - OpenCompass - DEBUG - Registry node of opencompass has been automatically imported.
08/10 14:37:04 - OpenCompass - DEBUG - Modules of opencompass's mm_datasets registry have been automatically imported from opencompass.multimodal.datasets
08/10 14:37:04 - OpenCompass - DEBUG - Get class `MMBenchDataset` from "mm_datasets" registry in "opencompass"
08/10 14:37:04 - OpenCompass - DEBUG - Get class `MMBenchDataset` from "mm_datasets" registry in "opencompass"
08/10 14:37:05 - OpenCompass - DEBUG - Cannot auto import mmpretrain.registry, please check whether the package "mmpretrain" is installed correctly or import the registry manually.
Traceback (most recent call last):
  File "/xxxxxxxxx/opencompass/run.py", line 381, in <module>
    main()
  File "/xxxxxxxxx/opencompass/run.py", line 222, in main
    exec_mm_infer_runner(tasks, args, cfg)
  File "/xxxxxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner
    runner(tasks)
  File "/xxxxxxxxx/opencompass/opencompass/runners/base.py", line 38, in __call__
    status = self.launch(tasks)
  File "/xxxxxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch
    task.run()
  File "/xxxxxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 121, in run
    dataloader = Runner.build_dataloader(self.dataloader)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/runner/runner.py", line 1353, in build_dataloader
    dataset = DATASETS.build(dataset_cfg)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/xxxxxxxxx/opencompass/opencompass/multimodal/datasets/mmbench.py", line 37, in __init__
    self.pipeline = Compose(pipeline)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/dataset/base_dataset.py", line 36, in __init__
    transform = TRANSFORMS.build(transform)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/xxxxxxxxx/env/minigpt4/minigpt4/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
    raise KeyError(
KeyError: 'mmpretrain.torchvision/Resize is not in the mmengine::transform registry. Please check whether the value of `mmpretrain.torchvision/Resize` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

### Other information

以参考了issues里的那个mini-gpt4的问题，发现报错信息一模一样，也参考了他的解决办法，但还是无法解决

---------
更新一段日志，我打印了self.pipeline
具体信息如下：[{'interpolation': 3, 'size': (224, 224), 'type': 'mmpretrain.torchvision/Resize'}, {'type': 'mmpretrain.torchvision/ToTensor'}, {'mean': (0.48145466, 0.4578275, 0.40821073), 'std': (0.26862954, 0.26130258, 0.27577711), 'type': 'mmpretrain.torchvision/Normalize'}, {'algorithm_keys': ['question', 'category', 'l2-category', 'context', 'index', 'options_dict', 'options', 'split'], 'type': 'mmpretrain.PackInputs'}]

Please refer to my instruction [here](https://github.com/InternLM/opencompass/issues/160#issuecomment-1669190260)


Please refer to my instruction https://github.com/InternLM/opencompass/issues/160#issuecomment-1669190260
-----------------------------

按照步骤已经全部试过了，还是没有用，仍然是这个报错

From the command you provide and errors in your log, I think two things you should care about:

1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
2. You should install the latest version of MMPretrain.

Hope these can be helpful to you.

> From the command you provide and errors in your log, I think two things you should care about:
> 
> 1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
> 2. You should install the latest version of MMPretrain.
> 
> Hope these can be helpful to you.

启动时如果不加-m torch.distributed.launch，会报如下的错误：
/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments
  warnings.warn(
08/11 03:43:18 - OpenCompass - INFO - Partitioned into 1 tasks.
08/11 03:43:18 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults
08/11 03:43:18 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks
08/11 03:43:18 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass"
08/11 03:43:18 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer
Traceback (most recent call last):
  File "/xxxxxx/opencompass/run.py", line 381, in <module>
    main()
  File "/xxxxxx/opencompass/run.py", line 222, in main
    exec_mm_infer_runner(tasks, args, cfg)
  File "/xxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner
    runner(tasks)
  File "/xxxxxx/opencompass/opencompass/runners/base.py", line 38, in __call__
    status = self.launch(tasks)
  File "/xxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch
    task.run()
  File "/xxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 118, in run
    init_dist(self.cfg.launcher)
  File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 84, in init_dist
    _init_dist_pytorch(backend, init_backend=init_backend, **kwargs)
  File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 101, in _init_dist_pytorch
    rank = int(os.environ['RANK'])
  File "/opt/conda/envs/minigpt4/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'RANK'

MMPretrain安装的是1.0.1版本

Have you updated the ``main`` branch of opencompass on your local machine?

> Have you updated the `main` branch of opencompass on your local machine?

是的，本地项目已经是最新的代码了

> > From the command you provide and errors in your log, I think two things you should care about:
> > 
> > 1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
> > 2. You should install the latest version of MMPretrain.
> > 
> > Hope these can be helpful to you.
> 
> 启动时如果不加-m torch.distributed.launch，会报如下的错误： /opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments warnings.warn( 08/11 03:43:18 - OpenCompass - INFO - Partitioned into 1 tasks. 08/11 03:43:18 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults 08/11 03:43:18 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks 08/11 03:43:18 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass" 08/11 03:43:18 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer Traceback (most recent call last): File "/xxxxxx/opencompass/run.py", line 381, in main() File "/xxxxxx/opencompass/run.py", line 222, in main exec_mm_infer_runner(tasks, args, cfg) File "/xxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner runner(tasks) File "/xxxxxx/opencompass/opencompass/runners/base.py", line 38, in **call** status = self.launch(tasks) File "/xxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch task.run() File "/xxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 118, in run init_dist(self.cfg.launcher) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 84, in init_dist _init_dist_pytorch(backend, init_backend=init_backend, **kwargs) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 101, in _init_dist_pytorch rank = int(os.environ['RANK']) File "/opt/conda/envs/minigpt4/lib/python3.9/os.py", line 679, in **getitem** raise KeyError(key) from None KeyError: 'RANK'
> 
> MMPretrain安装的是1.0.1版本

运行命令不加-m torch.distributed.launch，针对os.environ['RANK']中None KeyError: 'RANK'的问题，在mm_infer.py文件118行之前增加几句环境变量的设置，详情如下。注：我的机器不是分布式机器，只有一个主机，一个GPU。

os.environ['RANK']='0'
os.environ['LOCAL_RANK']='0'
os.environ['WORLD_SIZE']='1'
os.environ['MASTER_ADDR']=IP地址
os.environ['MASTER_PORT']=未占用的端口号


> > > From the command you provide and errors in your log, I think two things you should care about:
> > > 
> > > 1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
> > > 2. You should install the latest version of MMPretrain.
> > > 
> > > Hope these can be helpful to you.
> > 
> > 
> > 启动时如果不加-m torch.distributed.launch，会报如下的错误： /opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments warnings.warn( 08/11 03:43:18 - OpenCompass - INFO - Partitioned into 1 tasks. 08/11 03:43:18 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults 08/11 03:43:18 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks 08/11 03:43:18 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass" 08/11 03:43:18 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer Traceback (most recent call last): File "/xxxxxx/opencompass/run.py", line 381, in main() File "/xxxxxx/opencompass/run.py", line 222, in main exec_mm_infer_runner(tasks, args, cfg) File "/xxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner runner(tasks) File "/xxxxxx/opencompass/opencompass/runners/base.py", line 38, in **call** status = self.launch(tasks) File "/xxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch task.run() File "/xxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 118, in run init_dist(self.cfg.launcher) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 84, in init_dist _init_dist_pytorch(backend, init_backend=init_backend, **kwargs) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 101, in _init_dist_pytorch rank = int(os.environ['RANK']) File "/opt/conda/envs/minigpt4/lib/python3.9/os.py", line 679, in **getitem** raise KeyError(key) from None KeyError: 'RANK'
> > MMPretrain安装的是1.0.1版本
> 
> 运行命令不加-m torch.distributed.launch，针对os.environ['RANK']中None KeyError: 'RANK'的问题，在mm_infer.py文件118行之前增加几句环境变量的设置，详情如下。注：我的机器不是分布式机器，只有一个主机，一个GPU。
> 
> os.environ['RANK']='0' os.environ['LOCAL_RANK']='0' os.environ['WORLD_SIZE']='1' os.environ['MASTER_ADDR']=IP地址 os.environ['MASTER_PORT']=未占用的端口号

配置了您上述所说的这些变量，但是在执行python run.py ./configs/multimodal/tasks.py --mm-eval -w ./outputs/minigpt_4 --debug时，仍然报raise KeyError(
KeyError: 'mmpretrain.torchvision/Resize is not in the mmengine::transform registry. Please check whether the value of `mmpretrain.torchvision/Resize` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'


> > > > From the command you provide and errors in your log, I think two things you should care about:
> > > > 
> > > > 1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
> > > > 2. You should install the latest version of MMPretrain.
> > > > 
> > > > Hope these can be helpful to you.
> > > 
> > > 
> > > 启动时如果不加-m torch.distributed.launch，会报如下的错误： /opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments warnings.warn( 08/11 03:43:18 - OpenCompass - INFO - Partitioned into 1 tasks. 08/11 03:43:18 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults 08/11 03:43:18 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks 08/11 03:43:18 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass" 08/11 03:43:18 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer Traceback (most recent call last): File "/xxxxxx/opencompass/run.py", line 381, in main() File "/xxxxxx/opencompass/run.py", line 222, in main exec_mm_infer_runner(tasks, args, cfg) File "/xxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner runner(tasks) File "/xxxxxx/opencompass/opencompass/runners/base.py", line 38, in **call** status = self.launch(tasks) File "/xxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch task.run() File "/xxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 118, in run init_dist(self.cfg.launcher) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 84, in init_dist _init_dist_pytorch(backend, init_backend=init_backend, **kwargs) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 101, in _init_dist_pytorch rank = int(os.environ['RANK']) File "/opt/conda/envs/minigpt4/lib/python3.9/os.py", line 679, in **getitem** raise KeyError(key) from None KeyError: 'RANK'
> > > MMPretrain安装的是1.0.1版本
> > 
> > 
> > 运行命令不加-m torch.distributed.launch，针对os.environ['RANK']中None KeyError: 'RANK'的问题，在mm_infer.py文件118行之前增加几句环境变量的设置，详情如下。注：我的机器不是分布式机器，只有一个主机，一个GPU。
> > os.environ['RANK']='0' os.environ['LOCAL_RANK']='0' os.environ['WORLD_SIZE']='1' os.environ['MASTER_ADDR']=IP地址 os.environ['MASTER_PORT']=未占用的端口号
> 
> 配置了您上述所说的这些变量，但是在执行python run.py ./configs/multimodal/tasks.py --mm-eval -w ./outputs/minigpt_4 --debug时，仍然报raise KeyError( KeyError: 'mmpretrain.torchvision/Resize is not in the mmengine::transform registry. Please check whether the value of `mmpretrain.torchvision/Resize` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

It seems that there is something wrong with your installation of MMPretrain. You can use following code to check that:

```python
from mmengine.registry import TRANSFORMS

resize_config = dict(type='mmpretrain.torchvision/Resize',
                               size=(224, 224),
                               interpolation=3)
resize_op = TRANSFORMS.build(resize_config)
```

Only if it does not raise any exceptions, that MMPretrain has been already successfully installed.

> > > > > From the command you provide and errors in your log, I think two things you should care about:
> > > > > 
> > > > > 1. The command `python -m torch.distributed.launch run.py configs/multimodal/tasks.py --mm-eval -w outputs/minigpt_4 --debug` to start evaluation is wrong, and you should use `python run.py configs/multimodal/tasks.py --mm-eval`
> > > > > 2. You should install the latest version of MMPretrain.
> > > > > 
> > > > > Hope these can be helpful to you.
> > > > 
> > > > 
> > > > 启动时如果不加-m torch.distributed.launch，会报如下的错误： /opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/utils/manager.py:113: UserWarning: <class 'mmengine.logging.logger.MMLogger'> instance named of OpenCompass has been created, the method `get_instance` should not accept any other arguments warnings.warn( 08/11 03:43:18 - OpenCompass - INFO - Partitioned into 1 tasks. 08/11 03:43:18 - OpenCompass - DEBUG - Task 0: minigpt-4-mmbench-opencompass.MMBenchDataset-opencompass.DumpResults 08/11 03:43:18 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks 08/11 03:43:18 - OpenCompass - DEBUG - Get class `MultimodalInferTask` from "task" registry in "opencompass" 08/11 03:43:18 - OpenCompass - DEBUG - An `MultimodalInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.mm_infer Traceback (most recent call last): File "/xxxxxx/opencompass/run.py", line 381, in main() File "/xxxxxx/opencompass/run.py", line 222, in main exec_mm_infer_runner(tasks, args, cfg) File "/xxxxxx/opencompass/run.py", line 324, in exec_mm_infer_runner runner(tasks) File "/xxxxxx/opencompass/opencompass/runners/base.py", line 38, in **call** status = self.launch(tasks) File "/xxxxxx/opencompass/opencompass/runners/local.py", line 62, in launch task.run() File "/xxxxxx/opencompass/opencompass/tasks/mm_infer.py", line 118, in run init_dist(self.cfg.launcher) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 84, in init_dist _init_dist_pytorch(backend, init_backend=init_backend, **kwargs) File "/opt/conda/envs/minigpt4/lib/python3.9/site-packages/mmengine/dist/utils.py", line 101, in _init_dist_pytorch rank = int(os.environ['RANK']) File "/opt/conda/envs/minigpt4/lib/python3.9/os.py", line 679, in **getitem** raise KeyError(key) from None KeyError: 'RANK'
> > > > MMPretrain安装的是1.0.1版本
> > > 
> > > 
> > > 运行命令不加-m torch.distributed.launch，针对os.environ['RANK']中None KeyError: 'RANK'的问题，在mm_infer.py文件118行之前增加几句环境变量的设置，详情如下。注：我的机器不是分布式机器，只有一个主机，一个GPU。
> > > os.environ['RANK']='0' os.environ['LOCAL_RANK']='0' os.environ['WORLD_SIZE']='1' os.environ['MASTER_ADDR']=IP地址 os.environ['MASTER_PORT']=未占用的端口号
> > 
> > 
> > 配置了您上述所说的这些变量，但是在执行python run.py ./configs/multimodal/tasks.py --mm-eval -w ./outputs/minigpt_4 --debug时，仍然报raise KeyError( KeyError: 'mmpretrain.torchvision/Resize is not in the mmengine::transform registry. Please check whether the value of `mmpretrain.torchvision/Resize` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'
> 
> It seems that there is something wrong with your installation of MMPretrain. You can use following code to check that:
> 
> ```python
> from mmengine.registry import TRANSFORMS
> 
> resize_config = dict(type='mmpretrain.torchvision/Resize',
>                                size=(224, 224),
>                                interpolation=3)
> resize_op = TRANSFORMS.build(resize_config)
> ```
> 
> Only if it does not raise any exceptions, that MMPretrain has been already successfully installed.

感谢大佬，果然是这个问题，之前使用pip安装的mmpretrain，后面参考MMPretrain的安装教程手动安一遍就可以了