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.tar.gz (10.1 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-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: canirun-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 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.tar.gz
Algorithm Hash digest
SHA256 dd3eb56e9c8f5331b2c50d304620f785a05589e61f5bb29eadf842247c309dab
MD5 8e9ae4bfcbcb50d8531240e620e629a9
BLAKE2b-256 89bd3fbe3fe8c49e1800fede15ba8344df1e6f1fd405b062b6e517dae8ff14c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for canirun-1.0.0.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-py3-none-any.whl.

File metadata

  • Download URL: canirun-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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-py3-none-any.whl
Algorithm Hash digest
SHA256 31eb66e26838427a1a7614025130ef0ad051afd7572ec5c64f9db65504afba61
MD5 559892ad272d3bb91cc85e35fdb6f7e5
BLAKE2b-256 2eaee8bd2d881f7897e640c44970f569eaef261e3baf196acc68cd3ba003c84b

See more details on using hashes here.

Provenance

The following attestation bundles were made for canirun-1.0.0-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