PaddleSeg icon indicating copy to clipboard operation
PaddleSeg copied to clipboard

Paddle在子进程中进行模型初始化,无法调用gpu

Open hsdjkfnsfc opened this issue 2 years ago • 0 comments

问题确认 Search before asking

Bug描述 Describe the Bug

import multiprocessing as mp from ppmatting.utils import get_image_list, Config, MatBuilder

def init_model(cfg_path, model_path): cfg = Config(cfg_path) builder = MatBuilder(cfg) paddleseg.utils.show_env_info() paddleseg.utils.show_cfg_info(cfg) paddleseg.utils.set_device("gpu") model = builder.model pre_process = Compose(builder.val_transforms) utils.utils.load_entire_model(model, model_path) model.eval() return model, pre_process

def init_model_segment(model_type): if model_type == "new_human": cfg_path = os.path.join(WORK_DIR, "PaddleSeg/Matting/configs/ppmatting/ppmatting-hrnet_w18-human_1024.yml") model_path = os.path.join(WORK_DIR, "PaddleSeg/Matting/save_models/model/T4W5/model.pdparams") model, pre_process = matting_init_model(cfg_path, model_path) return model, pre_process

process = mp.Process(target=init_model_segment, args=("new_human")) process.start() process.join()

复现环境 Environment

OS:linux PaddlePaddle-gpu:2.5.0 python:3.9 cuda11.7

Bug描述确认 Bug description confirmation

  • [X] 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.

是否愿意提交PR? Are you willing to submit a PR?

  • [ ] 我愿意提交PR!I'd like to help by submitting a PR!

hsdjkfnsfc avatar Aug 02 '23 13:08 hsdjkfnsfc