Scikit-learn machine learning models training using multiple CPUs

允我心安 提交于 2021-02-19 06:50:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!