code: def _get_available_gpus(log=True):
      """Detect the GPUs available on the device and their available resources"""
      try:
          gpu_query = [
              "nvidia-smi",
              "--query-gpu=name,memory.free",
              "--format=csv",
          ]
          gpu_info_csv = subprocess.run(
              gpu_query, stdout=subprocess.PIPE, check=True
          )
          gpu_info = gpu_info_csv.stdout.decode("utf-8").splitlines()[
              1:
          ]
  
          if log:
              logger.info(
                  "CUDA enabled hardware on the device: %s", gpu_info
              )
          return gpu_info
      except Exception as e:  # pylint: disable=W0703
          # for nvidia-smi to run, a cuda driver must be present
          logger.warning(
              "CUDA is not enabled on your device. %s. "
              "Please run ModelBuilder on CUDA enabled hardware "
              "to deploy locally.",
              str(e),
          )
          return None
  
file_path: sagemaker-python-sdk/src/sagemaker/serve/utils/local_hardware.py
imports: from __future__ import absolute_import
  import subprocess
  import multiprocessing
  import logging
  import shutil
  from math import ceil, floor
  from platform import system
  from pathlib import Path
  import psutil
  from sagemaker import Session
label_desc: Use image node_id 1 for calling a global function with example usage: _get_available_gpus(log) and returns: gpu_info, None