Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我希望添加模型评测显存释放功能,单卡24G评测llama3会显存不足 #3480

Closed
1 task done
Micla-SHL opened this issue Apr 27, 2024 · 3 comments
Closed
1 task done
Labels
solved This problem has been already solved.

Comments

@Micla-SHL
Copy link

Reminder

  • I have read the README and searched the existing issues.

Reproduction

CUDA_VISIBLE_DEVICES=0 USE_MODELSCOPE_HUB=1 python src/evaluate.py --model_name_or_path LLM-Research/Meta-Llama-3-8B-Instruct --template llama3 --finetuning_type lora --task ceval --split validation --lang zh --n_shot 5 --batch_size 4

Expected behavior

我希望在/LLaMA-Factory/src/llmtuner/eval/evaluator.py def eval(self) -> None: 函数下添加

            for i in trange(
                0, len(inputs), self.eval_args.batch_size, desc="Predicting batches", position=1, leave=False
            ):
                batch_input = self.tokenizer.pad(
                    inputs[i : i + self.eval_args.batch_size], return_attention_mask=True, return_tensors="pt"
                ).to(self.model.device)
                preds = self.batch_inference(batch_input)
                outputs += preds
                del batch_input                                        #add  code
                torch.cuda.empty_cache()                       #add  code

我在评测循环尾部添加了显存释放模块,我的操作是合法的吗? 有不利的地方吗? 它至少能让我在单卡24G上做评测

System Info

No response

Others

我还不会做github 代码提交,所以暂时以提问形式作补充:

if 我的操作有什么更优的方式,希望能分享一下

@Naozumi520
Copy link

Do smaller batch_size help? I see you using batch size 4. I'm doing full parameter finetuning with badam so I think you should be able to do eval by lower the batch_size...

@hiyouga
Copy link
Owner

hiyouga commented Apr 27, 2024

--batch_size 1

@hiyouga hiyouga added the solved This problem has been already solved. label Apr 27, 2024
@hiyouga hiyouga closed this as completed Apr 27, 2024
@Micla-SHL
Copy link
Author

Do smaller batch_size help? I see you using batch size 4. I'm doing full parameter finetuning with badam so I think you should be able to do eval by lower the batch_size...

谢谢,我在刚提交该问题的时候考虑过batch_size, 它不太是我想解决的办法,所以还是想问问看,我这样纯粹的释放显存,有没有不好的地方

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved.
Projects
None yet
Development

No branches or pull requests

3 participants