1

I am trying to calculate the power consumption of a tensorRT script written in Python. With CUDA there is nvprof cuda_script, but couldn't find something like that for my Python script.

Is there something similar for Python? How are people calculating the power consumption of p100/v100?

Something like this for Nvidia GPUs - How to profile CPU usage of a Python script?

Nyla Worker
  • 133
  • 2
  • 11

2 Answers2

0

Turns out that running this process within one python file in a threaded way is very complicated. The solution is to run them in concurrently with bash and then make the power script check if the other process is running. Sample code bellow:

def measurePower():

    tmp = os.popen("ps -Af").read()
    process_name = "PROCESSTOBEMEASURED.PY"
    power_measurement = []

    '''One checks if the other process is still running, if yes it measures power again.'''
    while(process_name in tmp[:]):
        measurementPower = os.popen("nvidia-smi -i 0 -q").read()
        tmp = os.popen("ps -Af").read()
        power_measurement.append(nvidiaSmiParser(measurementPower, ["Power Draw"],num))

    return power_measurement
Nyla Worker
  • 133
  • 2
  • 11
0

You can use eco2AI library to estimate power consumption. https://github.com/sb-ai-lab/Eco2AI

It was designed to track CO2 emissions during ML models training, but it also measures power consumption of the GPU, CPU and RAM separately.

Igor
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 17 '23 at 12:31