Replies: 1 comment
|
There is no universally correct worker count; it is the smallest count that keeps the accelerator/training step fed without creating CPU, memory, or storage contention. In this example, image reading is I/O-heavy, while decoding and resizing may use CPU in native libraries. Threads can work well when those libraries release the GIL; multiprocessing is more useful for genuinely Python-bound CPU work, but has higher startup, serialization, and memory costs. I would benchmark
If you enable multiprocessing, keep the dataset picklable, avoid sharing open file handles, and use the normal |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm thinking of using
PyDatasetbut trying to understand first from first principles (before just testing) whether it makes sense to use a certain number of workers.Here is an example from the docs:
I'd guess that in this case the main reason to use multithreading and several workers would be to get a fast
resizingbut otherwise the operation will mostly involve I/O operations and not CPU processing.So data-loading when a bit of processing is done to the data would be a good use case for multi threading & workers ? And what about a reasonable number of workers? Is there a way to know the maximum available?
All reactions