llm-mem
llm-mem is a lightweight Python CLI tool designed to calculate the GPU VRAM requirements for models on Hugging Face. It estimates the memory usage based on the model parameters, selected data type, and desired context length. This tool is ideal for developers and researchers looking to optimize model deployment and resource allocation.
Features
- GPU VRAM Estimation: Calculate the VRAM needed for both the model and its key-value cache based on the provided context size.
- Support for Multiple Data Types: Choose from various data types (int4, int8, float8, float16, float32).
- Hugging Face Integration: Automatically fetch model configuration and metadata from Hugging Face repositories.
- Command-Line Interface: Simple and intuitive CLI for quick usage without any additional UI dependencies.
Usage
You can use the llm-mem command from your terminal. The CLI accepts the model ID, data type, and context size as arguments.
Command-Line Arguments
- -m or --model: (Required) The Hugging Face model ID.
- -d or --data-type: The data type for the model (choices: int4, int8, float8, float16, float32). Default is float16.
- -c or --context-size: The context size for the model. Default is 8192.
Example
uvx llm-mem -m google/gemma-3-27b-it -d float16 -c 128000
The above command will display an estimation of the model VRAM, context VRAM, and the total VRAM required.
Installation
You can install the package using Hatchling or your preferred Python package installer if the package is published on PyPI.
# Using pip (if published on PyPI)
uv venv
source .venv/bin/activate
uv pip install llm-mem
# Or clone the repository and install locally
git clone https://github.com/mathiasesn/llm-mem.git
cd llm-mem
pip install .
Directory Structure
├── README.md
├── llm_memory
│ ├── __init__.py
│ ├── cli.py
│ └── llm_memory_calculator.py
└── pyproject.toml
Development
If you wish to contribute or modify the package:
Clone the repository
git clone https://github.com/mathiasesn/llm-mem.git
cd llm-mem
Install development dependencies
uv venv
uv pip install -e .
Run tests
uv run pytest
License
This project is licensed under the terms specified in the LICENSE file.
Metadata
Release files for llm-mem 0.1.1
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 | |
|---|---|---|---|---|
| llm_mem-0.1.1.tar.gz | 33.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_mem-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.5 kB
Release files / llm_mem-0.1.1.tar.gz
| Download URL | llm_mem-0.1.1.tar.gz |
|---|---|
| Size | 33.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa889df45c37fffdc56c8cc7c9256f7cab12b457532fe568b137d0212297d7f9
|
|
BLAKE2b-256 checksum How to use checksums |
b31e0362b0ccb8ea0b98ac896593bb14b7359e64216030ffa255b4eedacf91f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Apr 1, 2025.
Transparency logRelease files / llm_mem-0.1.1-py3-none-any.whl
| Download URL | llm_mem-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
410de38dd081192ac0a734d319a8e143eadb8da25c6fffe4b8ad8f8a39552691
|
|
BLAKE2b-256 checksum How to use checksums |
4b82a54205c3b77dcab1070c3e6ef25f0eb9f0f4e7e7522e29a403e4764f25c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Apr 1, 2025.
Transparency logSecurity for llm-mem 0.1.1
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 llm_mem-0.1.1.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 Apr 1, 2025.
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.