  #!/usr/bin python3
  """ Information on available Nvidia GPUs """
  
  import pynvml
  
  
  class GPUStats(object):
      """ Holds information about system GPU(s) """
      def __init__(self):
 
</s> remove             pynvml.nvmlShutdown()
 </s> add             if not is_macos:
                pynvml.nvmlShutdown() </s> remove         vram = [pynvml.nvmlDeviceGetMemoryInfo(handle).free / (1024 * 1024)
                for handle in self.handles]
 </s> add         if is_macos:
            vram = [pynvx.cudaGetMemFree(handle, ignore=True) / (1024 * 1024)
                    for handle in self.handles]
        else:
            vram = [pynvml.nvmlDeviceGetMemoryInfo(handle).free / (1024 * 1024)
                    for handle in self.handles] </s> remove             try:
                pynvml.nvmlInit()
            except pynvml.NVMLError_LibraryNotFound:
                self.initialized = True
                return
 </s> add             if is_macos:
                try:
                    pynvx.cudaInit()
                except RuntimeError:
                    self.initialized = True
                    return
            else:
                try:
                    pynvml.nvmlInit()
                except pynvml.NVMLError_LibraryNotFound:
                    self.initialized = True
                    return </s> remove         self.handles = [pynvml.nvmlDeviceGetHandleByIndex(i)
                        for i in range(self.device_count)]
 </s> add         if is_macos:
            self.handles = pynvx.cudaDeviceGetHandles(ignore=True)
        else:
            self.handles = [pynvml.nvmlDeviceGetHandleByIndex(i)
                            for i in range(self.device_count)] </s> remove         try:
            self.device_count = pynvml.nvmlDeviceGetCount()
        except pynvml.NVMLError:
            self.device_count = 0
 </s> add         if is_macos:
            self.device_count = pynvx.cudaDeviceGetCount(ignore=True)
        else:
            try:
                self.device_count = pynvml.nvmlDeviceGetCount()
            except pynvml.NVMLError:
                self.device_count = 0
import platform

if platform.system() == 'Darwin':
    import pynvx
    is_macos = True
else:
    import pynvml
    is_macos = False
  #!/usr/bin python3
  """ Information on available Nvidia GPUs """
  
import platform

if platform.system() == 'Darwin':
    import pynvx
    is_macos = True
else:
    import pynvml
    is_macos = False
  
  
  class GPUStats(object):
      """ Holds information about system GPU(s) """
      def __init__(self):
keep keep keep replace keep keep keep keep keep
 Fixed face extract with dlib on OS X (#510)

* fix: gpu stat for OS X
- Use pynvx to get GPU info on OS X
- fix face extract with dlib

Issue #488 
lib/gpu_stats.py