memory
sleap_nn.config_generator.memory
¶
Memory estimation utilities for training configuration.
This module provides tools for estimating GPU and CPU memory requirements based on training configuration parameters.
Classes:
| Name | Description |
|---|---|
MemoryEstimate |
Memory estimation for training configuration. |
Functions:
| Name | Description |
|---|---|
estimate_memory |
Estimate GPU and CPU memory requirements (matches web app formula). |
MemoryEstimate
dataclass
¶
Memory estimation for training configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
model_weights_mb |
float
|
Estimated model weights memory in MB. |
batch_images_mb |
float
|
Estimated batch images memory in MB. |
activations_mb |
float
|
Estimated activations memory in MB. |
gradients_mb |
float
|
Estimated gradients memory in MB. |
confmaps_mb |
float
|
Estimated confidence maps memory in MB. |
total_gpu_mb |
float
|
Total estimated GPU memory in MB. |
cache_memory_mb |
float
|
Estimated CPU cache memory in MB. |
gpu_status |
Literal['green', 'yellow', 'red']
|
Status indicator (green, yellow, red). |
gpu_message |
str
|
Human-readable GPU memory message. |
cpu_fits_in_memory |
bool
|
Whether cache fits in available RAM. |
cpu_message |
str
|
Human-readable CPU memory message. |
params_count |
int
|
Estimated number of model parameters. |
Methods:
| Name | Description |
|---|---|
__str__ |
Return human-readable summary. |
Source code in sleap_nn/config_generator/memory.py
cache_memory_gb
property
¶
Cache memory in GB.
total_gpu_gb
property
¶
Total GPU memory in GB.
__str__()
¶
Return human-readable summary.
Source code in sleap_nn/config_generator/memory.py
estimate_memory(stats, backbone='unet_medium_rf', batch_size=4, input_scale=1.0, output_stride=1, filters=32, filters_rate=1.5, max_stride=16, num_keypoints=None)
¶
Estimate GPU and CPU memory requirements (matches web app formula).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stats
|
DatasetStats
|
DatasetStats from analyze_slp(). |
required |
backbone
|
str
|
Backbone architecture name. |
'unet_medium_rf'
|
batch_size
|
int
|
Training batch size. |
4
|
input_scale
|
float
|
Input image scaling factor. |
1.0
|
output_stride
|
int
|
Output stride for confidence maps. |
1
|
filters
|
int
|
Base number of filters (for UNet). |
32
|
filters_rate
|
float
|
Filter multiplier per block (for UNet). |
1.5
|
max_stride
|
int
|
Maximum stride (determines encoder depth). |
16
|
num_keypoints
|
int
|
Number of keypoints (defaults to stats.num_nodes). |
None
|
Returns:
| Type | Description |
|---|---|
MemoryEstimate
|
MemoryEstimate with breakdown and recommendations. |
Source code in sleap_nn/config_generator/memory.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |