如何进行多卡inference?[API Design]
在lmflow.pipeline.inferencer.Inferencer中,默认只使用了1块GPU
self.local_rank = int(os.getenv("LOCAL_RANK", "0"))
要如何做可以进行多卡inference
时长记录: 训练 1000条QA数据,10epoch, 8卡3090, 时长6小时 推理165条数据,单卡3090,时长6小时43分钟
训练和推理使用的deepspeed config均为config/ds_config_zero3_for_eval
这个指令不是默认使用一块GPU,os.getenv("LOCAL_RANK") 就是在获取当前GPU编号。 在这个文件里,把CUDA_VISIBLE_DEVICES改成多卡试试 https://github.com/OptimalScale/LMFlow/blob/main/scripts/run_evaluation_with_lora.sh
This command does not use a GPU by default, os.getenv("LOCAL_RANK") is to get the current GPU number. In this file, try changing CUDA_VISIBLE_DEVICES to multi-gpu https://github.com/OptimalScale/LMFlow/blob/main/scripts/run_evaluation_with_lora.sh
这个指令不是默认使用一块GPU,os.getenv("LOCAL_RANK") 就是在获取当前GPU编号。 在这个文件里,把CUDA_VISIBLE_DEVICES改成多卡试试 https://github.com/OptimalScale/LMFlow/blob/main/scripts/run_evaluation_with_lora.sh
This command does not use a GPU by default, os.getenv("LOCAL_RANK") is to get the current GPU number. In this file, try changing CUDA_VISIBLE_DEVICES to multi-gpu https://github.com/OptimalScale/LMFlow/blob/main/scripts/run_evaluation_with_lora.sh
使用了双卡3090进行测试,仍然大概是3分钟推理出一条数据
CUDA_VISIBLE_DEVICES=0,1 \
deepspeed examples/new_get_answer1.py \
--deepspeed configs/ds_config_zero3_for_eval.json \
--model_name_or_path ${model} \
这里是我的代码:https://gist.github.com/AlphaGogoo/c9095e0c001bd8a052a707581f80ad8e
If gpu memory allowed, you can use deepspeed zero 2 config which is much faster than zero 3. 3 min for one example seems you are offloading something to cpu, normally should be 5s per example.
This issue has been marked as stale because it has not had recent activity. If you think this still needs to be addressed please feel free to reopen this issue. Thanks