Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deep_cache_cleaner-1.0.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deep_cache_cleaner-1.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file deep_cache_cleaner-1.0.1.tar.gz.

File metadata

  • Download URL: deep_cache_cleaner-1.0.1.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

Hashes for deep_cache_cleaner-1.0.1.tar.gz
Algorithm Hash digest
SHA256 00b733212e67cddcfff0fd6aaef27197aa30a5c6ff67699515f85606f5cdc20c
MD5 ca91770dd5328238a4187be85686b220
BLAKE2b-256 87f16ed71614b4330e39eab269617eb582a598a980a66e200638a80e3453977f

See more details on using hashes here.

File details

Details for the file deep_cache_cleaner-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for deep_cache_cleaner-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e7079fd60aac27f568a9e650eb04244452ac9974a773436d10d8b3f6d18046
MD5 9a8d3305e415c63eaa57510f48c10f16
BLAKE2b-256 29390bd8ff1f4e71d562729613826f0ba3639c80f761dcc39b323d5ee4bfe609

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page