Skip to main content

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.

PyPI version License: MIT

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:

  1. Fetching the model's configuration from the Hugging Face Hub.
  2. Calculating the memory required for the model's parameters.
  3. Estimating the size of the KV cache based on the context length and model architecture.
  4. 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

canirun-1.0.0.post1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

canirun-1.0.0.post1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file canirun-1.0.0.post1.tar.gz.

File metadata

  • Download URL: canirun-1.0.0.post1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for canirun-1.0.0.post1.tar.gz
Algorithm Hash digest
SHA256 0c32eebd671039339271faaf36266a9e4a4a226caffeca3778bd1ccab6375907
MD5 c8f406ce26f6c14099e72bf5c546f39e
BLAKE2b-256 4d199837dd82e3a0ab5d70f56d4d9aa0b7d590000288903ead01ecea6ae65c40

See more details on using hashes here.

Provenance

The following attestation bundles were made for canirun-1.0.0.post1.tar.gz:

Publisher: publish.yml on PythonicVarun/canirun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file canirun-1.0.0.post1-py3-none-any.whl.

File metadata

  • Download URL: canirun-1.0.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for canirun-1.0.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 30ca291a1dde9c0795bf3b2096e0fec28bbccd6340f035a17868ef35c0f0ba93
MD5 9862c586abd8e6a44962f75156898a57
BLAKE2b-256 b5ab1064f9f87184b80aa6b26f92332311c2c10ae40981acb135a28331c60096

See more details on using hashes here.

Provenance

The following attestation bundles were made for canirun-1.0.0.post1-py3-none-any.whl:

Publisher: publish.yml on PythonicVarun/canirun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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