Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mr-talhailyas/tensorflow-keras-model-profiler
Tensorflow-Keras Model Profiler: Tells you model's memory requirement, no. of parameters, flops etc.
https://github.com/mr-talhailyas/tensorflow-keras-model-profiler
gpu gpu-memory-profiler model-flops model-params tensorflow
Last synced: 8 days ago
JSON representation
Tensorflow-Keras Model Profiler: Tells you model's memory requirement, no. of parameters, flops etc.
- Host: GitHub
- URL: https://github.com/mr-talhailyas/tensorflow-keras-model-profiler
- Owner: Mr-TalhaIlyas
- License: mit
- Created: 2021-04-07T10:03:48.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T22:38:37.000Z (over 1 year ago)
- Last Synced: 2025-02-03T20:02:30.453Z (8 days ago)
- Topics: gpu, gpu-memory-profiler, model-flops, model-params, tensorflow
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 27
- Watchers: 1
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![]()
[![Downloads](https://pepy.tech/badge/model-profiler)](https://pepy.tech/project/model-profiler) [![Generic badge](https://img.shields.io/badge/Version-1.1.8-.svg)](https://shields.io/)
# Tensorflow/ Keras Model Profiler
Gives you some basic but important information about your `tf` or `keras` model like,
* Model Parameters
* Model memory requirement on GPU
* Memory required to store parameters `model weights`.
* GPU availability and GPU IDs if available
#### Version 1.1.7 fixes problems with custom sequential models and includes other minor improvements.#### [Learning-Rate-Schedulers-Packege-Tensorflow-PyTorch-Keras](https://github.com/Mr-TalhaIlyas/Learning-Rate-Schedulers-Packege-Tensorflow-PyTorch-Keras)
#### [Loss-Functions-Package-Tensorflow-Keras-PyTorch](https://github.com/Mr-TalhaIlyas/Loss-Functions-Package-Tensorflow-Keras-PyTorch)## Dependencies
```
python >= 3.6
numpy
tabulate
tensorflow >= 2.0.0
keras >= 2.2.4
```
Built and tested on `tensorflow == 2.3.1`## Installation
using pip.
```
pip install model-profiler
```
or latest version from [PyPI project site](https://pypi.org/project/model-profiler/)
## UsageFirs load any model built using keras or tensorflow. Here for simplicity we will load model from kera applications.
```python
form tensorflow.keras.applications import VGG16model = VGG16(include_top=True, weights="imagenet", input_tensor=None,
input_shape=None, pooling=None, classes=1000,
classifier_activation="softmax")
```Now after installing `model_profiler` run
```python
from model_profiler import model_profilerBatch_size = 128
profile = model_profiler(model, Batch_size)print(profile)
```
`Batch_size` have effect on `model` memory usage so GPU memory usage need `batch_size`, it's default value if `1`.### Output
```
| Model Profile | Value | Unit |
|----------------------------------|---------------------|---------|
| Selected GPUs | ['0', '1'] | GPU IDs |
| No. of FLOPs | 0.30932349055999997 | BFLOPs |
| GPU Memory Requirement | 7.4066760912537575 | GB |
| Model Parameters | 138.357544 | Million |
| Memory Required by Model Weights | 527.7921447753906 | MB |
```
Default units for the prfiler are```
# in order
use_units = ['GPU IDs', 'BFLOPs', 'GB', 'Million', 'MB']```
You can change units by changing the list entry in appropriate location. For example if you want to get `model` FLOPs in million just change the list as follows.```
# keep order
use_units = ['GPU IDs', 'MFLOPs', 'GB', 'Million', 'MB']
```
### Availabel units are
```
'GB':memory unit gega-byte
'MB': memory unit mega-byte
'MFLOPs': FLOPs unit million-flops
'BFLOPs': FLOPs unit billion-flops
'Million': paprmeter count unit millions
'Billion': paprmeter count unit billions```
## More ExamplesFor further details and more examples visit my [github](https://github.com/Mr-TalhaIlyas/Tensorflow-Keras-Model-Profiler)