I have a system with 60 CPUs. I want to apply a Keras Neural Net model prediction on 60 cores in parallel. How should I force each parallel process to use only 1 of the 60 cores?
from pandarallel import pandarallel
pandarallel.initialize(nb_workers=60)
def my_func(path):
# probably something should be added here to restrict tensorflow.keras model.predict to only one CPU
return my_model.predict(load_and_preprocess(path))
df['prediction'] = df.parallel_apply(lambda x: my_func(x['image_path']))
The problem is that at the moment, this code runs non-stop forever while it finishes in 10 seconds for a DataFrame of length 10.