PaddleHelix icon indicating copy to clipboard operation
PaddleHelix copied to clipboard

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

Open lonngxiang opened this issue 2 years ago • 6 comments

image

lonngxiang avatar Mar 06 '22 02:03 lonngxiang

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

lonngxiang avatar Mar 06 '22 02:03 lonngxiang

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__)

Noisyntrain avatar Mar 08 '22 12:03 Noisyntrain

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

lonngxiang avatar Mar 08 '22 12:03 lonngxiang

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

Noisyntrain avatar Mar 08 '22 13:03 Noisyntrain

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 avatar Mar 08 '22 13:03 lonngxiang

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

lonngxiang avatar Mar 08 '22 13:03 lonngxiang