Comprehensive cache clearing utility for PyTorch, HuggingFace, and other ML libraries
Project description
File: README.md
Deep Cache Cleaner
A comprehensive cache clearing utility for PyTorch, HuggingFace, and other ML libraries.
Features
- 🧹 Clear PyTorch GPU memory cache
- 🤗 Clear HuggingFace transformers cache
- 📝 Clear sentence-transformers cache
- 🗑️ Clear Python pycache directories
- 📊 Check cache sizes and GPU memory usage
- 💣 Aggressive cleanup mode (deletes downloaded models)
- 🔧 Command-line interface
- 📦 Easy to use Python API
Installation
pip install deep-cache-cleaner
Optional Dependencies
For full functionality, install with optional dependencies:
# For HuggingFace transformers support
pip install deep-cache-cleaner[transformers]
# For sentence-transformers support
pip install deep-cache-cleaner[sentence-transformers]
# For development
pip install deep-cache-cleaner[dev]
Usage
Command Line Interface
# Clear all caches
deep-cache-cleaner clear
# Check cache sizes
deep-cache-cleaner check
# Aggressive cleanup (deletes downloaded models)
deep-cache-cleaner aggressive
# Auto-confirm aggressive cleanup
deep-cache-cleaner aggressive --yes
# Quiet mode
deep-cache-cleaner clear --quiet
Python API
import cache_cleaner
# Clear all caches
cache_cleaner.clear_all_caches()
# Check cache sizes
sizes = cache_cleaner.check_cache_sizes()
print(f"Total cache size: {sizes['Total']:.2f} GB")
# Aggressive cleanup
cache_cleaner.aggressive_cache_clear()
# Use the class interface for more control
cleaner = cache_cleaner.CacheCleaner(verbose=True)
cleaner.clear_all_caches()
What Gets Cleared
Standard Cleanup (clear)
- PyTorch GPU memory cache
- Python garbage collection
- In-memory HuggingFace model cache
- Python pycache directories
- Reports on cache sizes and temp files
Aggressive Cleanup (aggressive)
⚠️ Warning: This deletes downloaded models!
Everything from standard cleanup, plus:
- HuggingFace cache directory (
~/.cache/huggingface) - Sentence-transformers cache (
~/.cache/sentence_transformers) - Torch cache directory (
~/.cache/torch) - Cache directories from environment variables
Requirements
- Python 3.8+
- PyTorch (for GPU cache clearing)
- Optional: transformers, sentence-transformers
License
MIT License
Contributing
Contributions welcome! Please read our contributing guidelines and submit pull requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deep_cache_cleaner-1.0.0.tar.gz.
File metadata
- Download URL: deep_cache_cleaner-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b34e8875d32e736d35eb8d21c997f0d1f849dcc541455c9d5960649eb2cf77a0
|
|
| MD5 |
44c26bd390044040f18e657d7e9becc4
|
|
| BLAKE2b-256 |
142eb61eef074b488785ea196c7b4af99d37631e11e9a3377b6f4ed3c56014e1
|
File details
Details for the file deep_cache_cleaner-1.0.0-py3-none-any.whl.
File metadata
- Download URL: deep_cache_cleaner-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45fda2cb65d32ec2fdd9a1b3e7f2b17b27022ab2c252bde22e914cbf6d9b93e7
|
|
| MD5 |
ac7010059526b56d1d2f18a43d0d82a4
|
|
| BLAKE2b-256 |
7aea76c9e02b1b6676a68e36012b6841d3597b4c6a90daf3e38c99eeb46b2558
|