profiling
zeus.profiling
Helpers for profiling energy and time inside a training script.
ProfilingResult
dataclass
Profiling result of one window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
float
|
Time elapsed (in seconds) within the profiling window. |
required |
energy |
list[float]
|
A list of energy consumption (in Joules) within the profiling window for each GPU. |
required |
Source code in zeus/profiling.py
36 37 38 39 40 41 42 43 44 45 46 |
|
ZeusProfilingService
Profiles and energy and time inside a training script.
Push a profiling window to start profiling and pop to get the profiling result of the last pushed profiling window. Multiple nested profiling windows are supported using a stack.
Integrated Example
prof_service = zeus.profiling.ZeusProfilingService(gpu_handles, monitor_path, power_log_prefix)
# Push a profile window
prof_service.push_window()
# Actual work
training(x, y)
# Pop a profile window and get the profiling result
prof_result = prof_service.pop_window()
time_consumed, energy_consumed = prof_result.time, prof_result.energy
print(f"Training takes {time_consumed} seconds.")
for gpu_idx, energy_consumed_per_gpu in energy_consumed:
print(f"GPU {gpu_idx} consumes {energy_consumed_per_gpu} Joules.")
Please checkout out ZeusDataLoader
for a
complete integrated example.
Source code in zeus/profiling.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
__init__
__init__(
gpu_indices=None,
monitor_path="zeus_monitor",
monitor_log_dir="",
monitor_log_prefix="",
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gpu_indices |
list[int] | None
|
Indices of all the devices that will be used for training. If None, all the GPUs
available will be used. (Default: |
None
|
monitor_path |
str
|
The path to zeus monitor executable. (Default: |
'zeus_monitor'
|
monitor_log_dir |
str
|
The directory where monitor logging files will be saved. If not provided, a
temporary directory will be created. (Default: |
''
|
monitor_log_prefix |
str
|
The prefix of monitor logging files for power polling. (Default: |
''
|
Source code in zeus/profiling.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 |
|
_monitor_log_path
_monitor_log_path(gpu_index)
Return the path of power log file for one gpu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gpu_index |
int
|
The index of GPU. |
required |
Source code in zeus/profiling.py
136 137 138 139 140 141 142 143 144 145 146 |
|
_start_monitors
_start_monitors()
Spawn monitor processes for power polling for GPUs with older architecture.
Raises:
Type | Description |
---|---|
`ValueError`
|
|
Source code in zeus/profiling.py
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 |
|
_stop_monitors
_stop_monitors()
Kill the power monitor subprocess.
Source code in zeus/profiling.py
187 188 189 190 191 192 193 194 |
|
push_window
push_window()
Push one profiling window to the stack.
Source code in zeus/profiling.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
pop_window
pop_window()
Pop one profiling window out of the stack, returns the time consumption and energy consumption for each GPU.
Returns:
Type | Description |
---|---|
ProfilingResult
|
An object of |
Raises:
Type | Description |
---|---|
`RuntimeError`
|
The stack that stores profiling windows is empty. Users should always call |
Source code in zeus/profiling.py
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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
_log
_log(message, gpu_index=None, level=logging.INFO)
Print out message with prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to log out. |
required |
gpu_index |
int | None
|
The index of GPU for GPU-level logging. Should be |
None
|
level |
int
|
The logging level to use. (Default: |
logging.INFO
|
Source code in zeus/profiling.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|