PaddlePaddle / PaddleHelix

Bio-Computing Platform Featuring Large-Scale Representation Learning and Multi-Task Deep Learning “螺旋桨”生物计算工具集
Apache License 2.0
804 stars 190 forks source link

引入包运行报错ValueError: cannot find context for 'fork' #169

Open lonngxiang opened 2 years ago

lonngxiang commented 2 years ago

image

lonngxiang commented 2 years ago

import paddle import paddle.nn as nn import paddle.distributed as dist import pgl

import multiprocessing

multiprocessing.set_start_method("spawn")

from pahelix.model_zoo.pretrain_gnns_model import PretrainGNNModel, AttrmaskModel from pahelix.datasets.zinc_dataset import load_zinc_dataset from pahelix.utils.splitters import RandomSplitter from pahelix.featurizers.pretrain_gnn_featurizer import AttrmaskTransformFn, AttrmaskCollateFn from pahelix.utils import load_json_config

Noisyntrain commented 2 years ago

Hi lonngxiang, thank you for using PaddleHelix. It seems like a problem with the python version. May I ask which version of python are you using? Also please provide the pgl version that you are using. You can run command like this to get the pgl version: import pgl and print(pgl.__version__)

lonngxiang commented 2 years ago

Hi lonngxiang, thank you for using PaddleHelix. It seems like a problem with the python version. May I ask which version of python are you using? Also please provide the pgl version that you are using. You can run command like this to get the pgl version: import pgl and print(pgl.__version__)

python 3.7.11; pgl 2.2.0, tks for u reply

Noisyntrain commented 2 years ago

Hi lonngxiang, I reproduced the problem that you met, and it may be caused by some changes in python conflicting with the pgl's default multiprocess settings. A temporary fix can be done by replacing the 19 line of the mp_reader.py multiprocessing.set_start_method("fork") with multiprocessing.set_start_method("spawn"). In my environment, this will solve the import issue, hope this can be helpful to you. By the way, the mp_reader.py's location can be got from the errors reported, like this image

lonngxiang commented 2 years ago

import multiprocessing

multiprocessing.set_start_method("spawn")

tks, it works. by the way,'multiprocessing.set_start_method("spawn")' must be changed in the mp_reader.py file

lonngxiang commented 2 years ago

Hi lonngxiang, I reproduced the problem that you met, and it may be caused by some changes in python conflicting with the pgl's default multiprocess settings. A temporary fix can be done by replacing the 19 line of the mp_reader.py multiprocessing.set_start_method("fork") with multiprocessing.set_start_method("spawn"). In my environment, this will solve the import issue, hope this can be helpful to you. By the way, the mp_reader.py's location can be got from the errors reported, like this image

tks, it works. by the way,'multiprocessing.set_start_method("spawn")' must be changed in the mp_reader.py file