A tool to estimate GPU memory requirements
Project description
cfit(Carbon Fit) - GPU Memory Estimator
cfit is a Python tool designed to estimate the GPU memory requirements of machine learning models. By analyzing model files and configurations from Hugging Face repositories, CFIT helps developers determine the memory demands for different precisions (e.g., 32-bit, 16-bit, 8-bit, 4-bit) and model sizes.
Features
- Estimate GPU Memory: Compute the required GPU memory for models hosted on Hugging Face using their file size and configuration.
- Support for Multiple Precisions: cfit supports calculating memory usage for 32-bit, 16-bit, 8-bit, and 4-bit precision models.
- Flexible Input: Calculate memory requirements based on either the number of parameters or the model file size.
- Human-Readable Output: Results are returned in human-readable formats such as GB or MB for easy understanding.
Installation
The easiest way to install this package is through pip
, using
pip install cfit
If you want to be sure you're getting the newest version, you can install it directly from github with
pip install git+https://github.com/jeonsworld/cfit.git
Usage
cfit provides two main ways to estimate the GPU memory requirements:
CLI
Usage:
cfit model_or_params -p [precision]
Args:
model_or_params
: The name of the model on Hugging Face Model Hub or the number of parameters.precision
: The precision of the model (e.g., "all", 32, 16, 8, 4). Default isall
.
Examples:
cfit from_hf HuggingFaceH4/zephyr-7b-beta -p auto
# Required GPU Memory[HuggingFaceH4/zephyr-7b-beta, precision: 16]: 16.19 GB
cfit from_params 175B -p auto
"""
Required GPU Memory[parameters: 175.0B]
- 32bit: 782.31 GB
- 16bit: 391.16 GB
- 8bit: 195.58 GB
- 4bit: 97.79 GB
"""
cfit from_params 175000000000 -p auto
"""
Required GPU Memory[parameters: 175.0B]
- 32bit: 782.31 GB
- 16bit: 391.16 GB
- 8bit: 195.58 GB
- 4bit: 97.79 GB
Library
- cfit.from_hf(model_name_or_path, precision)
- Args:
model_name_or_path
: The name of the model on Hugging Face Model Hub.precision
: (Optional) The precision of the model (e.g., "auto", "all", 32, 16, 8, 4). Default isauto
.
- Args:
Examples:
auto
precision
import cfit
result = cfit.from_hf("HuggingFaceH4/zephyr-7b-beta", precision="auto") # `auto` parameter estimate precision from model config
print(result)
# Required GPU Memory[HuggingFaceH4/zephyr-7b-beta, precision: 16]: 16.19 GB
all
precision
import cfit
result = cfit.from_hf("HuggingFaceH4/zephyr-7b-beta", precision="all") # `all` parameter estimate memory for all precisions
print(result)
"""
Required GPU Memory[HuggingFaceH4/zephyr-7b-beta, parameters: 14.5B]
- 32bit: 64.75 GB
- 16bit: 32.37 GB
- 8bit: 16.19 GB
- 4bit: 8.09 GB
"""
- Specific precision
import cfit
result = cfit.from_hf("HuggingFaceH4/zephyr-7b-beta", precision=8) # estimate memory for specific precision
print(result)
# Required GPU Memory[HuggingFaceH4/zephyr-7b-beta, precision: 8]: 16.19 GB
- From number of parameters
- cfit.from_params(num_params, precision)
- Args:
num_params
: The number of parameters in the model.precision
: (Optional) The precision of the model (e.g., "all", 32, 16, 8, 4). Default isall
.
- Args:
Examples:
import cfit
result = cfit.from_params("175B", precision="auto")
"""
Required GPU Memory[parameters: 175.0B]
- 32bit: 782.31 GB
- 16bit: 391.16 GB
- 8bit: 195.58 GB
- 4bit: 97.79 GB
"""
result = cfit.from_params(175000000000, precision="auto")
print(result)
"""
Required GPU Memory[parameters: 175.0B]
- 32bit: 782.31 GB
- 16bit: 391.16 GB
- 8bit: 195.58 GB
- 4bit: 97.79 GB
"""
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
File details
Details for the file cfit-0.1.0.post1.tar.gz
.
File metadata
- Download URL: cfit-0.1.0.post1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f99cf364762e6e5e84d20adf787ca416f64a8be38706a9944abebc42598979b |
|
MD5 | 1f52674e648c9b457a2518bd0c06771c |
|
BLAKE2b-256 | 935bbd814727659e1d48c71d57cf1463195bbffa2a8afca828f467248466857b |
File details
Details for the file cfit-0.1.0.post1-py3-none-any.whl
.
File metadata
- Download URL: cfit-0.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a57770c4de6f927f4f4496059ec91e1708a50a5bc8875d608ee6510c824e8418 |
|
MD5 | 8132372ed8c68136cb27938fc2bf793c |
|
BLAKE2b-256 | 09a28902e3b634ef8ecb4b817e2be182ca8bf401c871937c99f81ad809643c73 |