问题
I want to decrease training time of my models by using a high end EC2 instance. So I tried c5.18xlarge
instance with 2 CPUs and run a few models with parameter n_jobs=-1
but I noticed that only one CPU was utilized:
Can I somehow make Scikit-learn to use all CPUs?
回答1:
Try adding:
import multiprocessing
multiprocessing.set_start_method('forkserver')
at the top of your code, before running or importing anything. That's a well-known issue with multiprocessing in python.
来源:https://stackoverflow.com/questions/52146685/scikit-learn-machine-learning-models-training-using-multiple-cpus