I need to get the GPU-Power from a server . This should be done with nvidia-smi.
def getGpuPower(self):
splitedGpuPower = os.popen("nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounits").read().replace("\n", ",").split(",")
for x in range(4):
self.gpuPower += float(splitedGpuPower[x])
return self.gpuPower
I need a float number like 250,00
I actually get
( File "test1.py", line 22, in getGpuPower
self.gpuPower += float(splitedGpuPower[x])
ValueError: could not convert string to float:)
The output looks like this
$ nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounits
8.50
7.43
11.04
splitedGpuPower[x]and check if it is actually a float?nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounitscommand.float("")is what you are actually doing here.splitedGpuPowerwithout assuming a range, and skip empty strings, check my answer if it makes sense to you!