Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
parthraut committed Nov 2, 2024
1 parent c8fb3af commit 5f428ce
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions zeus/device/gpu/amd.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def getInstantPowerUsage(self) -> int:
"Please use `getAveragePowerUsage` instead."
)
# returns in W, convert to mW
return int(
return (
int(amdsmi.amdsmi_get_power_info(self.handle)["current_socket_power"])
* 1000
)
Expand All @@ -279,6 +279,12 @@ def supportsGetTotalEnergyConsumption(self) -> bool:
@_handle_amdsmi_errors
def getTotalEnergyConsumption(self) -> int:
"""Return the total energy consumption of the GPU since driver load. Units: mJ."""
if not self._supportsGetTotalEnergyConsumption:
raise gpu_common.ZeusGPUNotSupportedError(
"Total energy consumption is not supported on this AMD GPU. "
"This is because the result of `amdsmi.amdsmi_get_energy_count` is not accurate. "
"Please use `getAveragePowerUsage` or `getInstantPowerUsage` to calculate energy usage."
)
energy_dict = amdsmi.amdsmi_get_energy_count(self.handle)
if "energy_accumulator" in energy_dict: # Changed since amdsmi 6.2.1
energy = (
Expand Down Expand Up @@ -351,7 +357,7 @@ def _init_gpus(self) -> None:
gpu._supportsInstantPowerUsage = isinstance(
amdsmi.amdsmi_get_power_info(gpu.handle)["current_socket_power"],
int,
)
) # amdsmi.amdsmi_get_power_info["current_socket_power"] returns "N/A" if not supported

# set _supportsGetTotalEnergyConsumption for all GPUs
wait_time = 0.5 # seconds
Expand Down

0 comments on commit 5f428ce

Please sign in to comment.