ultralytics-disk-cache-hook
Keep Ultralytics disk caches off the dataset filesystem.
When training uses cache="disk", this package redirects image .npy files and dataset .cache files into a local cache directory on the training node. This is useful when datasets live on shared or network storage.
Install
pip install ultralytics-disk-cache-hook
The hook auto-enables itself in new Python processes after installation. It supports Ultralytics 8.4.0 through 8.4.84.
Use
Use Ultralytics normally. Set cache="disk" when you want disk caching:
from ultralytics import YOLO
YOLO("yolov8n.pt").train(data="coco128.yaml", cache="disk")
The original dataset directory remains unchanged. Cache files are written under the plugin cache root instead.
Configuration
| Setting | Default | Purpose |
|---|---|---|
| ULTRALYTICS_DISK_CACHE_TMPDIR | System temporary directory | Parent directory for the plugin cache |
| ULTRALYTICS_IMAGE_DISK_CACHE | 1 | Enable image .npy cache redirection |
| ULTRALYTICS_DATASET_META_CACHE | 1 | Enable dataset .cache redirection |
| ULTRALYTICS_FORCE_DISK_CACHE | 0 | Force BaseDataset cache arguments to disk |
For example, to use local NVMe storage:
export ULTRALYTICS_DISK_CACHE_TMPDIR=/local_nvme/tmp
Parameter forcing is off by default so normal Ultralytics cache behavior is preserved. In a managed training environment, enable it before Python starts:
export ULTRALYTICS_FORCE_DISK_CACHE=1
This changes BaseDataset cache values such as false, true, and "ram" to "disk". It does not cover classification datasets.
Slurm job-local temporary storage
This plugin works well with Slurm job-lifecycle-managed local temporary storage, such as job_container/tmpfs or a site-specific Prolog/Epilog setup. Those mechanisms create private local scratch space for a job and remove its contents when the job ends.
If the job-local directory is mounted as /tmp, no extra setting is needed because that is the default cache parent. If your cluster exposes another job-local path, point the plugin at it:
export ULTRALYTICS_DISK_CACHE_TMPDIR=/path/to/job-local-scratch
Each job then keeps cache files off the shared dataset filesystem and they are reclaimed with the job-local temporary storage.
Cache layout
The default cache root is:
<system-temp-dir>/ultralytics-disk-cache
Each source path is hashed, then stored in two hash-bucket directories. Image caches use .npy and dataset metadata uses .cache.
Notes
- The plugin patches Ultralytics internals and rejects unsupported versions.
- Disk-space checks are skipped because the cache root may be outside the dataset filesystem. Ensure the selected cache disk has enough free space.
- The upstream proposal for native configurable disk-cache paths is Add cache_dir support for disk image caching. Follow its progress if you need first-party support.
Metadata
Release files for ultralytics-disk-cache-hook 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ultralytics_disk_cache_hook-0.3.0.tar.gz | 8.9 kB | With provenance | Details for ultralytics_disk_cache_hook-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ultralytics_disk_cache_hook-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ultralytics_disk_cache_hook-0.3.0-py3-none-any.whl |
Total release size: 18.2 kB
Release files / ultralytics_disk_cache_hook-0.3.0.tar.gz
| Download URL | ultralytics_disk_cache_hook-0.3.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15398d9d3c356cc63bba54a03ac132cc64ec0c6078faf2dad9f5b85301fb00c8
|
|
BLAKE2b-256 checksum How to use checksums |
2bc5adfc737a91af0c97ef92f3187d6193d6171d0b1dc24c5edf7373c9f7e04d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logRelease files / ultralytics_disk_cache_hook-0.3.0-py3-none-any.whl
| Download URL | ultralytics_disk_cache_hook-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c832d84fe87b61cc12b63de085c0712508a9c955c5be3da8be77b6bca6db6f6
|
|
BLAKE2b-256 checksum How to use checksums |
0060006a6e420f902b9c4d6e5b57444115947ed82332f873af289b67a115e4af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logSecurity for ultralytics-disk-cache-hook 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ultralytics_disk_cache_hook-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.