mmfewshot配置

基配置础信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 关于mmfewshot
1. 配置时间:2023/12/10
2. mmfewshot版本: 0.1.0

# 关于mmcv
1. mmcv 2.x版本之前叫做mmcv-full
2. mmcv 2.x版本之后改名
--之前-- |--现在--
mmcv-full | mmcv
mmcv | mmcv-lite
3. mmcv是2023年4月份才改名的,所以mmfewshot要安装mmcv-full这个名字


# 关于mmdet
1. mmdet 3.x版本之前的版本,mmdet/datasets/custome.py文件用到的numpy的一个方法是np.int,这个是numpy的1.20版本丢弃的,所以使用mmdet3.x之前的版本要安装numpy 1.20一下办的
2. 使用mmdet3.x的版本会提示,mmcv版本过低,需要安装mmcv2.x版本(但是mmcv-full这个版本最高只能是1.x,所以无解(不知道理解的对不对)),意味着mmfewshot 0.1.0可能不支持mmdet3.x版本


# 总之:
mmcv
mmdet
mmfewshot
这三个库之间的版本相互依赖,所以要安装对应的版本,否则会报错

安装

  1. 安装mmcv-full(如果已经有mmcv,需要把mmcv卸载)
1
2
3
# 这个要加上-f参数,不然 MMCV CUDA Compiler: not available
# MMCV CUDA Compiler: 10.1 是正确的
pip install mmcv-full==1.5.0 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.7.0/index.html
  1. 安装mmdet
1
pip install mmdet==2.24.0
  1. 安装mmcls,这个库好像没有特别大的区别
1
pip install mmcls==0.23.2
  1. 安装mmfewshot
1
2
3
4
5
# git下来之后进入mmfewshot目录

pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"

  1. 安装numpy
1
2
3
4
5
pip install numpy==1.19.5
# matplotlib和pandas现在要求的最低的numpy版本是1.20.0,所以要安装旧版的pandas和matplotlib
# 这两个版本是支持numpy1.19.5的
pip install matplotlib==3.6.0
pip install pandas==1.4.4
  1. 最后的版本
1
2
3
4
5
6
7
mmcls                   0.23.2
mmcv-full 1.5.0
mmdet 2.24.0
mmfewshot 0.1.0
Pillow 8.4.0
pandas 1.4.4
matplotlib 3.6.0

### 可能的报错

  1. TypeError: FormatCode() got an unexpected keyword argument 'verify'

Issue

安装yapf解决

1
pip install yapf==0.40.1
  1. RuntimeError: roi_align_forward_impl: implementation for device cuda:0 not found.

运行mmfewshot/utils/collect_env.py的文件,看看cuda是否可用,安装对应的cuda版本
参考上面 安装mmcv-full

1
pip install mmcv -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.7.0/index.html
  1. 初始安装版本不对的报错

Issue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
===================================
mmcls 0.25.0 https://github.com/open-mmlab/mmclassification
mmcv-lite 2.1.0 https://github.com/open-mmlab/mmcv
mmdet 3.0.0 https://github.com/open-mmlab/mmdetection
mmengine 0.10.1 https://github.com/open-mmlab/mmengine

GPU 0: Tesla V100-SXM2-32GB (UUID: GPU-828d98d3-ad2a-0a92-d4d9-0dac21a5439f)
/public/home/zhaol/syxue20225227095/fewshotdetection/mmfewshot-main
Traceback (most recent call last):
File "tools/detection/train.py", line 12, in <module>
from mmcv import Config, DictAction
ImportError: cannot import name 'Config' from 'mmcv' (/public/home/zhaol/anaconda3/envs/syxue2/lib/python3.8/site-packages/mmcv/__init__.py)

===================================
mmcls 0.25.0 https://github.com/open-mmlab/mmclassification
mmcv 2.1.0 https://github.com/open-mmlab/mmcv
mmdet 3.2.0 https://github.com/open-mmlab/mmdetection
mmengine 0.10.1 https://github.com/open-mmlab/mmengine
GPU 0: Tesla V100-SXM2-32GB (UUID: GPU-828d98d3-ad2a-0a92-d4d9-0dac21a5439f)
/public/home/zhaol/syxue20225227095/fewshotdetection/mmfewshot-main
Traceback (most recent call last):
File "tools/detection/train.py", line 12, in <module>
from mmcv import Config, DictAction
ImportError: cannot import name 'Config' from 'mmcv' (unknown location)
===================================
mmcls 0.25.0 https://github.com/open-mmlab/mmclassification
mmdet 3.0.0 https://github.com/open-mmlab/mmdetection
mmengine 0.10.1 https://github.com/open-mmlab/mmengine
mmcv-full 1.7.1 https://github.com/open-mmlab/mmcv
GPU 0: Tesla V100-SXM2-32GB (UUID: GPU-828d98d3-ad2a-0a92-d4d9-0dac21a5439f)
/public/home/zhaol/syxue20225227095/fewshotdetection/mmfewshot-main
/public/home/zhaol/anaconda3/envs/syxue2/lib/python3.8/site-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
warnings.warn(
Traceback (most recent call last):
File "tools/detection/train.py", line 15, in <module>
from mmdet.utils import collect_env
File "/public/home/zhaol/anaconda3/envs/syxue2/lib/python3.8/site-packages/mmdet/__init__.py", line 16, in <module>
assert (mmcv_version >= digit_version(mmcv_minimum_version)
AssertionError: MMCV==1.7.1 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.1.0.
  1. RuntimeError: CUDA error: no kernel image is available for execution on the device 错误

安装的pytorch版本和cuda版本不对应
刚开始安装的pytorch 1.6.0 + cuda 10.1,

1
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117

第二次安装完成-增加xformers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
conda create -n mmfew python=3.9
conda activate mmfew

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
conda install linux-64_xformers-0.0.22-py39_cu11.6.2_pyt1.12.1.tar.bz2
pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.12/index.html
pip install mmdet==2.24.0 mmcls==0.23.2

cd mmfewshot-main
pip install -r requirements/build.txt
pip install -v -e .

pip install yapf==0.40.1
pip install triton