Exemplo n.º 1
0
def test_nvmlDeviceGetTotalEnergyConsumption(ngpus, handles):
    for i in range(ngpus):
        energy_mJoules1 = pynvml.nvmlDeviceGetTotalEnergyConsumption(handles[i])
        for j in range(10):  # idle for 150 ms
            time.sleep(0.015)  # and check for increase every 15 ms
            energy_mJoules2 = pynvml.nvmlDeviceGetTotalEnergyConsumption(handles[i])
            assert energy_mJoules2 >= energy_mJoules1
            if energy_mJoules2 > energy_mJoules1:
                break
        else:
            assert False, "energy did not increase across 150 ms interval"
Exemplo n.º 2
0
 def get_energy(self):
     return [
         pynvml.nvmlDeviceGetTotalEnergyConsumption(handle)
         for handle in self._handle
     ]