open-compass / opencompass

OpenCompass is an LLM evaluation platform, supporting a wide range of models (Llama3, Mistral, InternLM2,GPT-4,LLaMa2, Qwen,GLM, Claude, etc) over 100+ datasets.
https://opencompass.org.cn/
Apache License 2.0
3.85k stars 406 forks source link

[Bug] 评估过程中的oom 问题 #1587

Open tonney007 opened 1 day ago

tonney007 commented 1 day ago

先决条件

问题类型

我正在使用官方支持的任务/模型/数据集进行评估。

环境

·

重现问题 - 代码/配置示例

·

重现问题 - 命令或脚本

python run.py --datasets mmlu_gen --hf-type chat --hf-path /opt/ml/code/qwen/Qwen2-72B-Instruct --debug

重现问题 - 错误信息

100%|███████████████████████████████████████████████████████████████████████████████████████████████| 112/112 [44:40<00:00, 23.94s/it] 09/30 13:06:58 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_computer_security] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 1487341.84it/s] [2024-09-30 13:06:58,982] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 13:06:58,982] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 13/13 [04:09<00:00, 19.21s/it] 09/30 13:11:18 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_microeconomics] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 238/238 [00:00<00:00, 2156035.32it/s] [2024-09-30 13:11:19,261] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 13:11:19,261] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [06:28<00:00, 12.95s/it] 09/30 13:17:58 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_professional_law] 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1534/1534 [00:00<00:00, 3075555.61it/s] [2024-09-30 13:17:59,863] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 13:17:59,863] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 192/192 [2:29:15<00:00, 46.64s/it] 09/30 15:47:25 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_medical_genetics] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 1823610.43it/s] [2024-09-30 15:47:25,957] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 15:47:25,957] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 13/13 [03:23<00:00, 15.67s/it] 09/30 15:50:59 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_professional_psychology] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 612/612 [00:00<00:00, 3290915.45it/s] [2024-09-30 15:51:00,537] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 15:51:00,537] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 77/77 [28:02<00:00, 21.85s/it] 09/30 16:19:12 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_jurisprudence] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 108/108 [00:00<00:00, 1919427.25it/s] [2024-09-30 16:19:13,098] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:19:13,099] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 14/14 [02:18<00:00, 9.91s/it] 09/30 16:21:42 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_world_religions] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 171/171 [00:00<00:00, 2084959.26it/s] [2024-09-30 16:21:42,817] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:21:42,817] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 22/22 [01:15<00:00, 3.43s/it] 09/30 16:23:08 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_philosophy] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 311/311 [00:00<00:00, 2304644.07it/s] [2024-09-30 16:23:08,912] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:23:08,913] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 39/39 [05:29<00:00, 8.44s/it] 09/30 16:28:48 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_virology] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 166/166 [00:00<00:00, 1468891.27it/s] [2024-09-30 16:28:48,414] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:28:48,414] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 21/21 [02:51<00:00, 8.19s/it] 09/30 16:31:50 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_chemistry] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 203/203 [00:00<00:00, 2276587.47it/s] [2024-09-30 16:31:51,092] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:31:51,092] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [13:11<00:00, 30.43s/it] 09/30 16:45:13 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_public_relations] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 110/110 [00:00<00:00, 2068939.19it/s] [2024-09-30 16:45:13,323] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:45:13,323] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 14/14 [02:21<00:00, 10.08s/it] 09/30 16:47:44 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_macroeconomics] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 390/390 [00:00<00:00, 3040480.59it/s] [2024-09-30 16:47:45,346] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 16:47:45,346] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 49/49 [14:56<00:00, 18.29s/it] 09/30 17:02:51 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_human_sexuality] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 131/131 [00:00<00:00, 1701095.43it/s] [2024-09-30 17:02:52,042] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 17:02:52,043] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 17/17 [01:53<00:00, 6.66s/it] 09/30 17:04:55 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_elementary_mathematics] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 378/378 [00:00<00:00, 2893151.30it/s] [2024-09-30 17:04:56,363] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 17:04:56,364] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 48/48 [23:08<00:00, 28.92s/it] 09/30 17:28:15 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_physics] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 151/151 [00:00<00:00, 1632319.34it/s] [2024-09-30 17:28:15,705] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 17:28:15,705] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 19/19 [11:08<00:00, 35.17s/it] 09/30 17:39:34 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_computer_science] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 1839607.02it/s] [2024-09-30 17:39:34,526] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 17:39:34,526] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 13/13 [06:39<00:00, 30.76s/it] 09/30 17:46:25 - OpenCompass - INFO - Start inferencing [Qwen2-72B-Instruct_hf/lukaemon_mmlu_high_school_european_history] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 165/165 [00:00<00:00, 2225273.83it/s] [2024-09-30 17:46:25,305] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting build dataloader [2024-09-30 17:46:25,305] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 0%| | 0/21 [00:12<?, ?it/s] Traceback (most recent call last): File "/opt/ml/code/opencompass-main/run.py", line 4, in main() File "/opt/ml/code/opencompass-main/opencompass/cli/main.py", line 308, in main runner(tasks) File "/opt/ml/code/opencompass-main/opencompass/runners/base.py", line 38, in call status = self.launch(tasks) File "/opt/ml/code/opencompass-main/opencompass/runners/local.py", line 123, in launch task.run(cur_model=getattr(self, 'cur_model', File "/opt/ml/code/opencompass-main/opencompass/tasks/openicl_infer.py", line 89, in run self._inference() File "/opt/ml/code/opencompass-main/opencompass/tasks/openicl_infer.py", line 128, in _inference inferencer.inference(retriever, File "/opt/ml/code/opencompass-main/opencompass/openicl/icl_inferencer/icl_gen_inferencer.py", line 153, in inference results = self.model.generate_from_template( File "/opt/ml/code/opencompass-main/opencompass/models/base.py", line 201, in generate_from_template return self.generate(inputs, max_out_len=max_out_len, kwargs) File "/opt/ml/code/opencompass-main/opencompass/models/huggingface_above_v4_33.py", line 476, in generate outputs = self.model.generate(tokens, generation_kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/generation/utils.py", line 2048, in generate result = self._sample( File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/generation/utils.py", line 3008, in _sample outputs = self(model_inputs, return_dict=True) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/accelerate/hooks.py", line 170, in new_forward output = module._old_forward(*args, *kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 1167, in forward outputs = self.model( File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(*args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 976, in forward layer_outputs = decoder_layer( File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/accelerate/hooks.py", line 170, in new_forward output = module._old_forward(*args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 717, in forward hidden_states = self.mlp(hidden_states) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl return forward_call(args, kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/accelerate/hooks.py", line 170, in new_forward output = module._old_forward(*args, *kwargs) File "/opt/conda/envs/opencompass/lib/python3.10/site-packages/transformers/models/qwen2/modeling_qwen2.py", line 276, in forward return self.down_proj(self.act_fn(self.gate_proj(hidden_state)) self.up_proj(hidden_state)) torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 1.42 GiB. GPU 1 has a total capacity of 79.14 GiB of which 1.26 GiB is free. Process 116763 has 77.87 GiB memory in use. Of the allocated memory 74.22 GiB is allocated by PyTorch, and 3.15 GiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

其他信息

是需要在哪里做一个内存清理吗?

MaiziXiao commented 1 day ago

你用了多少张卡?

tonney007 commented 16 hours ago

你用了多少张卡?

两张80的,然后昨天数据集每次循环后边加了个简单清理也不好用~

del mmlu_infer_cfg
del mmlu_eval_cfg
import torch
torch.cuda.empty_cache()
import gc
gc.collect()
tonysy commented 8 hours ago

You can reduce the batch size. The default batch size is 8.