https://github.com/amenalahassa/model-weighter
A sample tool for estmating memory need to run a model
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (4.7%) to scientific vocabulary
Repository
A sample tool for estmating memory need to run a model
Basic Info
- Host: GitHub
- Owner: amenalahassa
- Language: Python
- Default Branch: main
- Size: 5.86 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
model-weighter
model-weighter is a Python package designed to estimate the memory requirements needed to run a neural network model. It provides a sample function that takes a dummy input and a model as input and outputs the required resources (CPU & GPU memory) for training and inference.
Features
- Estimate RAM usage during training and inference.
- Estimate GPU memory usage during training and inference (if a GPU is available).
Usage
```python import torch import torch.nn as nn from modelweighter import calculatememory_usage
Define a simple model for demonstration
class SimpleModel(nn.Module): def init(self): super(SimpleModel, self).init() self.fc1 = nn.Linear(784, 256) self.fc2 = nn.Linear(256, 128) self.fc3 = nn.Linear(128, 10)
def forward(self, x):
x = torch.flatten(x, 1)
x = torch.relu(self.fc1(x))
x = torch.relu(self.fc2(x))
x = self.fc3(x)
return x
model = SimpleModel() batchsize = 32 inputsize = (1, 28, 28) # Example for MNIST dataset
ramusagetraining, ramusageinference, gpuusagetraining, gpuusageinference = calculatememoryusage(model, batchsize, inputsize)
print(f"Estimated RAM usage during training: {ramusagetraining / (1024 ** 2):.2f} MB") print(f"Estimated RAM usage during inference: {ramusageinference / (1024 ** 2):.2f} MB") print(f"Estimated GPU usage during training: {gpuusagetraining / (1024 ** 2):.2f} MB" if gpuusagetraining else "GPU not available") print(f"Estimated GPU usage during inference: {gpuusageinference / (1024 ** 2):.2f} MB" if gpuusageinference else "GPU not available") ```
Owner
- Name: Konrad Tagnon Amen ALAHASSA
- Login: amenalahassa
- Kind: user
- Location: Québec
- Repositories: 1
- Profile: https://github.com/amenalahassa
👋 I'm an enthusiastic explorer in the realms of AI and machine learning, let's connect and explore how we can innovate together! 🚀
GitHub Events
Total
Last Year
Dependencies
- torch *