New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add memory cache limit #10258
base: main
Are you sure you want to change the base?
Add memory cache limit #10258
Conversation
I have read the CLA Document and I sign the CLA |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10258 +/- ##
==========================================
- Coverage 70.66% 70.49% -0.18%
==========================================
Files 122 122
Lines 15591 15600 +9
==========================================
- Hits 11018 10997 -21
- Misses 4573 4603 +30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…Dou/ultralytics into feature/set-dataset-cache-limit
Added an additional test case for low ram limit setting |
Got the following failure from github actions: =========================== short test summary info ============================ However, I passed the same test on my local machine: ========================================================== test session starts =========================================================== tests/test_python.py . [100%] ========================================================== slowest 30 durations ========================================================== (2 durations < 0.005s hidden. Use -vv to show these durations.) |
Hey there! It seems like you encountered an issue when running GitHub Actions for exporting to CoreML, but it worked fine on your local setup. 🤔 This discrepancy might be due to differences in the environment setup, library versions, or even the PyTorch and torchvision versions between your local machine and the GitHub Actions runner. A potential step to align both environments more closely could involve ensuring that the same versions of PyTorch, torchvision, and coremltools are used in both cases. You could verify and match these versions in your GitHub Actions workflow file, possibly by setting up a more explicit environment for your tests. Here's a quick example on how you could specify versions in your workflow: - name: Set up Python
uses: actions/setup-python @PacificDou
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install torch==<your_version> torchvision==<your_version> coremltools==<your_version>
pip install -r requirements.txt Replace |
Hi @glenn-jocher , I tried the main branch with original code (no change), got the same error for the same test case on github actions. So I guess there might be some version conflict in the test scripts. It seems that your recent commit fixed it!! |
@PacificDou thanks for opening a PR! Please also make sure to update the train arguments table in the documentation. Additionally, we appreciate any unit tests you can write to test the changes you're contributing. |
Hi @Burhan-Q , I updated the documentation and also added a test case. |
Description:
This PR is for the proposal mentioned at: #9871
Basically, it gives users the flexibility to control memory cache by the additional parameter
mem_cache_limit
(default is 0.7):mem_cache_limit
< 0.0: no cache will be used in memory (same ascache=False
);mem_cache_limit
< 1.0: use fraction of current available memory;mem_cache_limit
> 1.0: use the value as it is, unit is byte.For example:
mem_cache_limit=0.7
: 70% of current available memory;mem_cache_limit=1024*1024*1024
: 1024x1024x1024 Bytes = 1 GB.Please be noticed that, there will always be a (memory buffer)[https://github.com/ultralytics/ultralytics/blob/5a82b511074617b9daa25000e5672c5d56188374/ultralytics/data/base.py#L87] inside the dataset, even if
case=disk
orcache=False
, to cache a few batches.If the required memory for this buffer is larger than
mem_cache_limit
, we'll still cache the images so the actual memory usage might be higher thanmem_cache_limit
. This should not be a problem, because this buffer is usually quite small.In addition, if multi-process workers are being used,
mem_cache_limit
only controls the memory usage inside a single worker process.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Introducing memory cache limits for improved data handling in training 🚀.
📊 Key Changes
mem_cache_limit
configuration option indefault.yaml
to control memory cache usage.🎯 Purpose & Impact
Overall, this update enhances the Ultralytics framework's usability and efficiency, especially in environments where memory is at a premium.