koila  by rentruewang

Tool to prevent CUDA out-of-memory errors in PyTorch

Created 3 years ago
1,832 stars

Top 23.6% on SourcePulse

GitHubView on GitHub
Project Summary

Koila is a Python library designed to prevent PyTorch's common "CUDA out of memory" errors with a single line of code. It targets PyTorch users, particularly those encountering memory limitations during model training, by automatically managing batch sizes and optimizing computation.

How It Works

Koila acts as a lightweight wrapper around PyTorch tensors. It employs a lazy evaluation strategy, similar to TensorFlow's static graphs, to build a computational graph before execution. By analyzing the shapes of intermediate tensors, Koila can predict memory requirements and dynamically adjust batch sizes to fit available GPU memory, preventing out-of-memory errors. It also automatically splits batches into powers of two for potential speedups.

Quick Start & Requirements

  • Install via pip: pip install koila
  • Requires PyTorch.
  • Refer to the v0.1.1 tag for a proof-of-concept.

Highlighted Details

  • Prevents CUDA out-of-memory errors with a single line of code.
  • Automatically accumulates gradients for large batch sizes.
  • Lazily evaluates PyTorch code to save computing power.
  • Splits batch dimensions automatically for GPU efficiency.

Maintenance & Community

The project is currently undergoing a significant re-structure, with the main branch being largely empty. The v0.1.1 tag represents a working proof-of-concept. The project is available under the Apache License.

Licensing & Compatibility

  • License: Apache License.
  • Compatible with PyTorch code.

Limitations & Caveats

The library is a work in progress and not yet fully PyTorch compatible due to limited development time. It is not recommended for production environments. The main branch is mostly empty due to ongoing re-structuring.

Health Check
Last Commit

4 days ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
3
Star History
3 stars in the last 30 days

Explore Similar Projects

Starred by Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral), Yaowei Zheng Yaowei Zheng(Author of LLaMA-Factory), and
4 more.

ml-cross-entropy by apple

0.4%
520
PyTorch module for memory-efficient cross-entropy in LLMs
Created 10 months ago
Updated 1 day ago
Starred by David Cournapeau David Cournapeau(Author of scikit-learn), Stas Bekman Stas Bekman(Author of "Machine Learning Engineering Open Book"; Research Engineer at Snowflake), and
5 more.

lectures by gpu-mode

0.8%
5k
Lecture series for GPU-accelerated computing
Created 1 year ago
Updated 4 days ago
Starred by Peter Norvig Peter Norvig(Author of "Artificial Intelligence: A Modern Approach"; Research Director at Google), Alexey Milovidov Alexey Milovidov(Cofounder of Clickhouse), and
29 more.

llm.c by karpathy

0.2%
28k
LLM training in pure C/CUDA, no PyTorch needed
Created 1 year ago
Updated 2 months ago
Feedback? Help us improve.