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:
autoprecision
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
allprecision
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.
Metadata
Release files for cfit 0.1.0.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cfit-0.1.0.post1.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cfit-0.1.0.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / cfit-0.1.0.post1.tar.gz
| Download URL | cfit-0.1.0.post1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f99cf364762e6e5e84d20adf787ca416f64a8be38706a9944abebc42598979b
|
|
BLAKE2b-256 checksum How to use checksums |
935bbd814727659e1d48c71d57cf1463195bbffa2a8afca828f467248466857b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / cfit-0.1.0.post1-py3-none-any.whl
| Download URL | cfit-0.1.0.post1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a57770c4de6f927f4f4496059ec91e1708a50a5bc8875d608ee6510c824e8418
|
|
BLAKE2b-256 checksum How to use checksums |
09a28902e3b634ef8ecb4b817e2be182ca8bf401c871937c99f81ad809643c73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|