Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using tf.keras.utils.Sequence with model.fit_generator with use_multiprocessing=True generated warning

This is the warning I got:

WARNING:tensorflow:multiprocessing can interact badly with TensorFlow, causing nondeterministic deadlocks. For high performance data pipelines tf.data is recommended.

The Sequence subclass I wrote strictly perform load and read I/O jpg files. I guess as long as no 2 threads do it simultaneously on the same file, things should be ok.

I trained for a few epoch and so far, there's no error. But would like to get feedback if there's something potentially bad that could happen.

like image 430
kawingkelvin Avatar asked Apr 03 '20 19:04

kawingkelvin


People also ask

Is Model Fit_generator deprecated?

Update July 2021: For TensorFlow 2.2+ users, just use the . fit method for your projects. The . fit_generator method will be deprecated in future releases of TensorFlow as the .

What is TF keras?

Keras is a deep learning API written in Python, running on top of the machine learning platform TensorFlow. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result as fast as possible is key to doing good research.


1 Answers

Initially in the TensorFlow 2.0 Version, there were issues with the keras.utils.Sequence with multiprocessing=True was causing a hang due to deadlock. Later in Tensorflow 2.1 this Warning was added to address this concern.

# use_multiprocessing=False works.
# use_multiprocessing=True hangs in a deadlock situation.
model.fit_generator(generator, use_multiprocessing=True, workers=2)  

You can ignore this warning since you are not doing any processing which will create deadlock situation.

like image 149
Tensorflow Warrior Avatar answered Oct 29 '22 13:10

Tensorflow Warrior