diff --git a/evolve.py b/evolve.py index 52c7efef36b97fb295fde5d99b0bea8aff75c213..2ff9ff3f662d608e8b3757df02ffadda35ded38b 100644 --- a/evolve.py +++ b/evolve.py @@ -39,6 +39,8 @@ if "__main__" == __name__: mstats = factory.get_stats() + multiprocessing.set_start_method('spawn') + pool = multiprocessing.Pool(conf["params"]["n_thread"], initializer=factory.init_global_var) evoTool.toolbox.register("map", pool.map) diff --git a/experiments/ADF.py b/experiments/ADF.py index e6b58592dceeb4849a601153803f35c8798e28ab..fc4f1b130fd079dee2a97b01c3e308f6f60f4c36 100644 --- a/experiments/ADF.py +++ b/experiments/ADF.py @@ -188,6 +188,8 @@ if __name__ == "__main__": conf = vars(args) initializer(conf) + multiprocessing.set_start_method('spawn') + stats_fit = tools.Statistics(lambda ind: ind.fitness.values[0]) stats_size = tools.Statistics(len) stats_bandit = tools.Statistics(lambda ind: len(ind.fitness.rewards)) diff --git a/experiments/bench.py b/experiments/bench.py index 07591d1e672a21b72b44fc4127aef4bccc260d19..e7f2593f7d0d7c3cd307ae14295a3ee17fcb1abc 100644 --- a/experiments/bench.py +++ b/experiments/bench.py @@ -148,7 +148,8 @@ if __name__ == "__main__": parser.add_argument("--path", help="directory for results", default="", type=str) args = parser.parse_args() - + multiprocessing.set_start_method('spawn') + if args.path == "": args.path = os.path.join("experiments", "results", "bench", ntpath.basename(args.conf)[:-4]) diff --git a/experiments/gp.py b/experiments/gp.py index 91966d6af80d464089133eb64920be34a6d1e068..7f57183767a1d16990b08b0f2e4228659ee7d3dd 100644 --- a/experiments/gp.py +++ b/experiments/gp.py @@ -170,6 +170,8 @@ if __name__== "__main__": mstats = factory.get_stats() + multiprocessing.set_start_method('spawn') + pool = multiprocessing.Pool(args.n_thread, initializer=factory.init_global_var) toolbox.register("map", pool.map) diff --git a/experiments/imitation_learning/imitation_gp.py b/experiments/imitation_learning/imitation_gp.py index a02b0776da1449dc4110c8c884eaeffe830eb8a5..59fca97512ad590e9f0351a7d42448bc41c6c84d 100644 --- a/experiments/imitation_learning/imitation_gp.py +++ b/experiments/imitation_learning/imitation_gp.py @@ -192,6 +192,7 @@ if __name__== "__main__": stats_size = tools.Statistics(len) stats_bandit = tools.Statistics(lambda ind: len(ind.fitness.rewards)) + multiprocessing.set_start_method('spawn') mstats = tools.MultiStatistics(fitness=stats_fit, size=stats_size, bandit=stats_bandit) mstats.register("avg", lambda x: np.mean(x, axis=0)) mstats.register("std", lambda x: np.std(x, axis=0)) diff --git a/experiments/imitation_learning/imitation_linGP.py b/experiments/imitation_learning/imitation_linGP.py index 59fe3d9d42835fa2df7bf96b84354642ac6dc673..2e361f34ddc2eeca978993c85b4785f749a5744a 100644 --- a/experiments/imitation_learning/imitation_linGP.py +++ b/experiments/imitation_learning/imitation_linGP.py @@ -157,6 +157,7 @@ if __name__== "__main__": data.extend(MC_collect_single(demonstrator.action, ENV, 1000)) dataset.core_transition(data) + multiprocessing.set_start_method('spawn') pool = multiprocessing.Pool(12, initializer=initializer, initargs=("AntPyBulletEnv-v0", 0, TimeFeatureWrapper)) toolbox.register("map", pool.map) diff --git a/experiments/linGP.py b/experiments/linGP.py index 7d70ef2d17ace3a6d149ae1bb772699a79226134..fc5ec8475e511147e686f89708d0b96636b792d9 100644 --- a/experiments/linGP.py +++ b/experiments/linGP.py @@ -166,7 +166,8 @@ if __name__ == '__main__': factory.init_global_var() mstats = factory.get_stats() - + + multiprocessing.set_start_method('spawn') pool = multiprocessing.Pool(args.n_thread, initializer=factory.init_global_var) toolbox.register("map", pool.map)