code: def run(self):
      self.connection.send(0)
      stop = False
  
      command = f"nvidia-smi --query-gpu=memory.used --format=csv --id={self.device_index}"
  
      while True:
          # py3nvml is broken since it outputs only the reserved memory, and nvidia-smi has only the MiB precision.
          gpu_mem_mb = (
              subprocess.check_output(command.split())
              .decode("ascii")
              .split("\n")[1]
              .split()[0]
          )
          gpu_mem_mb = int(gpu_mem_mb) * 1.048576
          self.mem_usage = max(self.mem_usage, gpu_mem_mb)
  
          if stop:
              break
          stop = self.connection.poll(self.interval)
  
      # send results to parent pipe
      self.connection.send(self.mem_usage)
      self.connection.close()
  
file_path: optimum/tests/benchmark/memory_tracker.py
imports: import os
  import subprocess
  from contextlib import contextmanager
  from multiprocessing import Pipe, Process
  from multiprocessing.connection import Connection
label_desc: Use image node_id 2 for calling the PeakMemoryMeasureProcess obj's underlying member method code with example usage: obj.run() without return types