class_docstr: Creates a context to query information
  
  Example:
  
      with NVMLContext() as ctx:
          num_gpus = ctx.num_devices()
          for device in ctx.devices():
              print(device.memory())
              print(device.utilization())
docstr: Get a specific GPU device
  
  Args:
      idx: index of device
  
  Returns:
      NvidiaDevice: single GPU device
docstr_tok: ["Get","a","specific","GPU","device","Args",":","idx",":","index","of","device","Returns",":","NvidiaDevice",":","single","GPU","device"]
code: def device(self, idx):
      """Get a specific GPU device
  
      Args:
          idx: index of device
  
      Returns:
          NvidiaDevice: single GPU device
      """
      num_dev = self.num_devices()
      assert (
          idx < num_dev
      ), "Cannot obtain device {}: NVML only found {} devices.".format(
          idx, num_dev
      )
  
      class GpuDevice(Structure):
          pass
  
      c_nvmlDevice_t = POINTER(GpuDevice)
  
      c_index = c_uint(idx)
      device = c_nvmlDevice_t()
      _check_return(
          _NVML.get_function("nvmlDeviceGetHandleByIndex_v2")(
              c_index, byref(device)
          )
      )
      return NvidiaDevice(device)
  
imports: import threading
  from ctypes import CDLL, POINTER, Structure, byref, c_uint, c_ulonglong, create_string_buffer
label_desc: Use image node_id 5 for calling the NVMLContext obj's underlying member method code with example usage: obj.device(idx) and returns: NvidiaDevice