torch
zeus.profile.torch
Defines the ProfileDataLoader class.
ProfileDataLoader
Bases: DataLoader
A DataLoader class that profiles power and time.
ProfileDataLoader
acts just like an ordinary
DataLoader
while profiling power
consumption and epoch latency under the hood. Power profiling is done by
spawning the Zeus power monitor as a subprocess. The latency of each epoch
will be printed out to stdout.
ProfileDataLoader
interfaces with the outside world with environment variables.
ZEUS_LOG_PREFIX
: Prefix for power and time log files. Power log:f"{log_prefix}+gpu{index}.power.csv"
Time log :f"{log_prefix}.time.csv"
ZEUS_MONITOR_PATH
: Path to the Zeus power monitor. (Default:"/workspace/zeus/zeus_monitor/zeus_monitor"
)ZEUS_MONITOR_SLEEP_MS
: How many milliseconds to sleep after measuring power. This is passed to the monitor. (Default:"100"
)
ProfileDataLoader
supports training on only a subset of the dataset and
scaling time measurements as if trained on the entire dataset.
ProfileDataLoader
will assume that training is happening on all GPUs visible
and spawn one Zeus power monitor process for each GPU. If this is not what you
want, set CUDA_VISIBLE_DEVICES
or spawn a Docker container that only mounts
the GPUs that you would like to use.
Source code in zeus/profile/torch.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 |
|
__init__
__init__(
*args,
batch_size,
split,
subset_proportion=1.0,
eat_batch_size=False,
only_scale_time=False,
**kwargs
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
Batch size to use. |
required |
split |
Literal['train', 'eval']
|
Dataset split. Used when printing out epoch latency. |
required |
subset_proportion |
float
|
Should be between 0.0 and 1.0. When specified, only that proportion of the dataset will be used and the dataloader will stop early. Then, the measured epoch latency will be scaled as if the whole datset was used. |
1.0
|
only_scale_time |
bool
|
If True, the whole dataset will be used for training, but
the measured epoch latency will still be scaled based on the value of
|
False
|
eat_batch_size |
bool
|
If True, does not pass the |
False
|
Source code in zeus/profile/torch.py
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 |
|
__iter__
__iter__()
Wrap the original __iter__
, but with power profiling.
Source code in zeus/profile/torch.py
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 |
|
__next__
__next__()
Wrap the original __next__
, but with power profiling.
Source code in zeus/profile/torch.py
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 |
|
kill_monitor
kill_monitor()
Kill all Zeus power monitors.
Source code in zeus/profile/torch.py
201 202 203 204 205 206 207 |
|