我以joblib 教程为例。这是我的代码的样子:
from math import sqrt
from joblib import Parallel, delayed
import multiprocessing
test = Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
print(test)
它产生以下错误消息:
Attempting to do parallel computing without protecting your import
on a system that does not support forking. To use parallel-computing
in a script, you must protect you main loop using
"if __name__ == '__main__'". Please see the joblib documentation on
Parallel for more information
而且运行时间太长。我错过了什么?