我想并行化一个用 joblib.Memory 缓存的函数,但是我收到以下错误:
TypeError: can't pickle function objects
这是代码:
import joblib
mem = joblib.Memory(cachedir='/tmp')
@mem.cache
def foo(x):
# do some complicated task
return x + 1
if __name__ == '__main__':
f = joblib.delayed(foo)
res = joblib.Parallel(n_jobs=-2)(f(x) for x in range(100))