aioway  by rentruewang

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

Created 4 years ago
1,824 stars

Top 23.3% 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)
28
Issues (30d)
45
Star History
0 stars in the last 30 days

Explore Similar Projects

Starred by Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera), Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral), and
5 more.

ml-cross-entropy by apple

0%
595
PyTorch module for memory-efficient cross-entropy in LLMs
Created 1 year ago
Updated 6 months ago
Starred by Sasha Rush Sasha Rush(Research Scientist at Cursor; Professor at Cornell Tech), Jeremy Howard Jeremy Howard(Cofounder of fast.ai), and
3 more.

tensordict by pytorch

0.1%
1k
PyTorch tensor container for efficient ML data handling
Created 3 years 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.3%
6k
Lecture series for GPU-accelerated computing
Created 2 years ago
Updated 2 months 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.5%
29k
LLM training in pure C/CUDA, no PyTorch needed
Created 2 years ago
Updated 9 months ago
Feedback? Help us improve.