@@ -150,45 +150,46 @@ def energy_compute(self) -> pm.EnergyResponse:
150
150
for _ in range (iterations ):
151
151
iteration (* inputs )
152
152
energy_measurer .end_measurement ()
153
-
154
- resp .total_consumption = energy_measurer .total_energy ()/ float (iterations )
155
-
156
- components = []
157
- components_joules = []
158
-
159
- if energy_measurer .cpu_energy () is not None :
160
- cpu_component = pm .EnergyConsumptionComponent ()
161
- cpu_component .component_type = pm .ENERGY_CPU_DRAM
162
- cpu_component .consumption_joules = energy_measurer .cpu_energy ()/ float (iterations )
163
- components .append (cpu_component )
164
- components_joules .append (cpu_component .consumption_joules )
165
- else :
166
- cpu_component = pm .EnergyConsumptionComponent ()
167
- cpu_component .component_type = pm .ENERGY_CPU_DRAM
168
- cpu_component .consumption_joules = 0.0
169
- components .append (cpu_component )
170
- components_joules .append (cpu_component .consumption_joules )
171
-
172
- gpu_component = pm .EnergyConsumptionComponent ()
173
- gpu_component .component_type = pm .ENERGY_NVIDIA
174
- gpu_component .consumption_joules = energy_measurer .gpu_energy ()/ float (iterations )
175
- components .append (gpu_component )
176
- components_joules .append (gpu_component .consumption_joules )
177
-
178
- resp .components .extend (components )
179
-
180
- # get last 10 runs if they exist
181
- path_to_entry_point = os .path .join (self ._project_root , self ._entry_point )
182
- past_runs = self ._energy_table_interface .get_latest_n_entries_of_entry_point (10 , path_to_entry_point )
183
- print (past_runs )
184
- resp .past_measurements .extend (_convert_to_energy_responses (past_runs ))
185
-
186
- # add current run to database
187
- self ._energy_table_interface .add_entry ([path_to_entry_point ] + components_joules )
188
-
189
153
except PermissionError as err :
190
154
# Remind user to set their CPU permissions
191
155
print (err )
156
+
157
+ resp .total_consumption = energy_measurer .total_energy ()/ float (iterations )
158
+ resp .batch_size = self ._batch_size
159
+
160
+ components = []
161
+ components_joules = []
162
+
163
+ if energy_measurer .cpu_energy () is not None :
164
+ cpu_component = pm .EnergyConsumptionComponent ()
165
+ cpu_component .component_type = pm .ENERGY_CPU_DRAM
166
+ cpu_component .consumption_joules = energy_measurer .cpu_energy ()/ float (iterations )
167
+ components .append (cpu_component )
168
+ components_joules .append (cpu_component .consumption_joules )
169
+ else :
170
+ cpu_component = pm .EnergyConsumptionComponent ()
171
+ cpu_component .component_type = pm .ENERGY_CPU_DRAM
172
+ cpu_component .consumption_joules = 0.0
173
+ components .append (cpu_component )
174
+ components_joules .append (cpu_component .consumption_joules )
175
+
176
+ gpu_component = pm .EnergyConsumptionComponent ()
177
+ gpu_component .component_type = pm .ENERGY_NVIDIA
178
+ gpu_component .consumption_joules = energy_measurer .gpu_energy ()/ float (iterations )
179
+ components .append (gpu_component )
180
+ components_joules .append (gpu_component .consumption_joules )
181
+
182
+ resp .components .extend (components )
183
+
184
+ # get last 10 runs if they exist
185
+ path_to_entry_point = os .path .join (self ._project_root , self ._entry_point )
186
+ past_runs = self ._energy_table_interface .get_latest_n_entries_of_entry_point (10 , path_to_entry_point )
187
+ resp .past_measurements .extend (_convert_to_energy_responses (past_runs ))
188
+
189
+ # add current run to database
190
+ current_entry = [path_to_entry_point ] + components_joules
191
+ current_entry .append (self ._batch_size )
192
+ self ._energy_table_interface .add_entry (current_entry )
192
193
return resp
193
194
194
195
def habitat_compute_threshold (self , runnable , context ):
@@ -602,5 +603,8 @@ def _convert_to_energy_responses(entries: list)-> List[pm.EnergyResponse]:
602
603
603
604
energy_response .total_consumption = gpu_component .consumption_joules + cpu_component .consumption_joules
604
605
energy_response .components .extend ([cpu_component , gpu_component ])
606
+
607
+ energy_response .batch_size = entry [3 ]
605
608
energy_response_list .append (energy_response )
609
+
606
610
return energy_response_list
0 commit comments