Check if you can run a Hugging Face model locally.
Project description
canirun
A lightweight CLI to estimate hardware requirements and quantization compatibility for Hugging Face models.
[!NOTE] Currently optimized for standard Transformer architectures (Llama, Mistral, Gemma, BERT). MoE and custom architectures may have experimental support.
Key Features
- Hardware Detection: Automatically detects your CPU/GPU and available VRAM/RAM.
- Memory Estimation: Estimates the memory required to run a given Hugging Face model.
- Quantization Analysis: Checks compatibility for different quantization levels (e.g., 4-bit, 8-bit, 16-bit).
- Simple CLI & API: Easy to use from the command line or integrate into your Python projects.
Installation
You can install canirun using pip:
pip install canirun
CLI Usage
The canirun command allows you to quickly check a model from your terminal.
canirun <model_id> [OPTIONS]
Example
Let's check if meta-llama/Meta-Llama-3-8B can run on the local hardware:
canirun meta-llama/Meta-Llama-3-8B --ctx 4096
This will produce a report like this:
๐ ANALYSIS REPORT: meta-llama/Meta-Llama-3-8B
Context Length : 4096
Device : NVIDIA GeForce RTX 3090
VRAM / RAM : 24.0 GB / 64.0 GB
โโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Quantization โ Total Est. โ KV Cache โ Compatibility โ
โโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโก
โ FP16 โ 16.96 GB โ 512.00 MB โ โ
GPU โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโค
โ INT8 โ 9.48 GB โ 512.00 MB โ โ
GPU โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 4-bit โ 6.30 GB โ 512.00 MB โ โ
GPU โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 2-bit โ 4.34 GB โ 512.00 MB โ โ
GPU โ
โโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโ
API Usage
You can also use canirun programmatically in your Python code.
from canirun import canirun
model_id = "mistralai/Mistral-7B-v0.1"
# Analyze the model
result = canirun(model_id, context_length=2048)
if result and result.is_supported:
print(f"'{model_id}' is supported on your hardware!")
# Get the detailed report
report = result.report()
for quant_result in report:
print(f"- {quant_result['quant']}: {quant_result['status']}")
else:
print(f"'{model_id}' is not supported on your hardware.")
How It Works
canirun works by:
- Fetching the model's configuration from the Hugging Face Hub.
- Calculating the memory required for the model's parameters.
- Estimating the size of the KV cache based on the context length and model architecture.
- Comparing the estimated memory requirements with your system's available VRAM (if a GPU is detected) or RAM.
The tool checks for different levels of quantization to see if a smaller, quantized version of the model could fit.
Development
This project maintains strict code quality standards:
- Formatter: Black
- Linter: Ruff
- Type Checking: MyPy (Strict)
- Docstrings: Google Style
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 canirun-1.0.1.tar.gz.
File metadata
- Download URL: canirun-1.0.1.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
519424ccd28d0c9a5051d745a1e95b7acccc670681cf306b935e63e8eb2ffbbb
|
|
| MD5 |
06be5548c7d145b07dc657d23390fd6f
|
|
| BLAKE2b-256 |
43fd3aa530ca4a0c61bc145b1232bd2d9559cc11089f3131f2e90f4541b4b905
|
Provenance
The following attestation bundles were made for canirun-1.0.1.tar.gz:
Publisher:
publish.yml on PythonicVarun/canirun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canirun-1.0.1.tar.gz -
Subject digest:
519424ccd28d0c9a5051d745a1e95b7acccc670681cf306b935e63e8eb2ffbbb - Sigstore transparency entry: 850117499
- Sigstore integration time:
-
Permalink:
PythonicVarun/canirun@ca0454774fc35ba0cc0c9db0815ce00732da9b16 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/PythonicVarun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ca0454774fc35ba0cc0c9db0815ce00732da9b16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file canirun-1.0.1-py3-none-any.whl.
File metadata
- Download URL: canirun-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc8cfdc63072781f9a32190f6f5a8274bc94933972011f3864046f01cacbd0df
|
|
| MD5 |
b72fb54117f0b87ad0d2bde0f5d0521f
|
|
| BLAKE2b-256 |
7910166438b0e82ec7ff1794d5a190ad5b5f8186575fc50dc4e8cb4a6c5b1d60
|
Provenance
The following attestation bundles were made for canirun-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on PythonicVarun/canirun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canirun-1.0.1-py3-none-any.whl -
Subject digest:
fc8cfdc63072781f9a32190f6f5a8274bc94933972011f3864046f01cacbd0df - Sigstore transparency entry: 850117500
- Sigstore integration time:
-
Permalink:
PythonicVarun/canirun@ca0454774fc35ba0cc0c9db0815ce00732da9b16 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/PythonicVarun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ca0454774fc35ba0cc0c9db0815ce00732da9b16 -
Trigger Event:
push
-
Statement type: