Multiprocessing using fit_generator(pickle_safe=True) fails
See original GitHub issueI’m trying to use fit_generator to seperate data loader from trainer.
model.fit_generator(data_gen(), samples_per_epoch=10000, nb_epoch=1, pickle_safe=True, verbose=0)
Excuting this code produces error like below:
Traceback (most recent call last):
File "main_generator.py", line 138, in <module>
model.fit_generator(data_gen(), samples_per_epoch=10000, nb_epoch=1, pickle_safe=True, verbose=0)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\keras\models.py", line 935, in fit_generator
initial_epoch=initial_epoch)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\keras\engine\training.py", line 1470, in fit_generator
pickle_safe=pickle_safe)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\keras\engine\training.py", line 436, in generator_queue
thread.start()
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\multiprocessing\context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\multiprocessing\context.py", line 313, in _Popen
return Popen(process_obj)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\multiprocessing\popen_spawn_win32.py", line 66, in __init__
reduction.dump(process_obj, to_child)
File "C:\dev\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\multiprocessing\reduction.py", line 59, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'generator_queue.<locals>.data_generator_task'
I also tried to test keras/tests/keras/test_multiprocessing.py, but it failed.
Here is output for test_multiprocessing.py: test_multiprocessing.faillog.txt
Is it bug of Keras itself? Any fixes available?
Issue Analytics
- State:
- Created 7 years ago
- Comments:28
Top Results From Across the Web
Keras "pickle_safe": What does it mean to be "pickle safe", or ...
According to Kera's docs: pickle_safe: If True, use process based threading. Note that because this implementation relies on multiprocessing, ...
Read more >Multiprocessing and Pickle, How to Easily fix that?
However, the multiprocess tasks can't be pickled; it would raise an error failing to pickle.
Read more >Tip – fit_generator in keras – how to parallelise correctly
With a thread-safe implementation, multiple workers have no problem with both use_multiprocessing = True / False .
Read more >How to Grid Search Hyperparameters for Deep Learning ...
when I am using the categorical_entropy loss function and running the grid search with n_jobs more than 1 its throwing error “cannot pickle...
Read more >Video classification with Keras and Deep Learning
There's a problem with this approach though — if you've ever tried ... video classification algorithm (the actual point of this tutorial), ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is still an issue for python 3.5, windows 7.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.