You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/28 23:30:48 UTC

[GitHub] zhreshold opened a new pull request #13447: Rewrite dataloader, improves responsiveness and reliability

zhreshold opened a new pull request #13447: Rewrite dataloader, improves responsiveness and reliability
URL: https://github.com/apache/incubator-mxnet/pull/13447
 
 
   ## Description ##
   Rewrite dataloader with multiprocess.pool, the logic of dataloader with `num_worker>0` is cleaner and more robust.
   
   Changes with this PR:
   
   - Secure MXIndexRecordIO reader handler with process id, note that to perseve perf, no lock is introduced, separate processes will obtain new handlers to the record file.  
   - Replaced manual queue handling with built-in `multiprocessing.Pool`, no matter how many epochs and iterators are launched, they share same process pool. The benefit is two fold: 1) It's faster, since new iterators will no longer trying to fork new processes 2) it's more reliable, the process pool is managed along with the entire life of dataloader, not iterators. 
   - __Benchmarked with ResNet 50 on ImageNet, p3-x16 instance with 8 GPUs and 60 CPU workers, images/sec bumped from (1500-2400) to (3000-3100), it's faster and more stable__
   - Added an option `prefetch=None`: 
   
   ```
   prefetch : int, default is `num_workers * 2`
           The number of prefetching batches only works if `num_workers` > 0.
           If `prefetch` > 0, it allow worker process to prefetch certain batches before
           acquiring data from iterators.
           Note that using large prefetching batch will provide smoother bootstrapping performance,
           but will consume more shared_memory. Using smaller number may forfeit the purpose of using
           multiple worker processes, try reduce `num_workers` in this case.
           By default it defaults to `num_workers * 2`.
   ```
   
   The rest functionality and APIs are intact with this PR. No action is required for exisiting users.
   
   Thanks @szha @leezu for the ideas.
   @piiswrong @eric-haibin-lin @hetong007 @YutingZhang  for review and questions
   
   This PR may affect gluoncv and gluonnlp dataloader variants, I will address them separately. 
   
   
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
   - Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services