      def shutdown(self):
          """ Shutdown pynvml """
          if self.initialized:
              self.handles = None
              pynvml.nvmlShutdown()
              self.initialized = False
  
      def get_device_count(self):
          """ Return count of Nvidia devices """
          try:
 
</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 </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 import pynvml
 </s> add import platform

if platform.system() == 'Darwin':
    import pynvx
    is_macos = True
else:
    import pynvml
    is_macos = False </s> remove         """ Return total vram in megabytes per device """
        vram = [pynvml.nvmlDeviceGetName(handle).decode("utf-8")
                for handle in self.handles]
        return vram
 </s> add         """ Return name of devices """
        self.initialize()
        if is_macos:
            names = [pynvx.cudaGetName(handle, ignore=True)
                    for handle in self.handles]
        else:
            names = [pynvml.nvmlDeviceGetName(handle).decode("utf-8")
                    for handle in self.handles]
        return names
            if not is_macos:
                pynvml.nvmlShutdown()
      def shutdown(self):
          """ Shutdown pynvml """
          if self.initialized:
              self.handles = None
            if not is_macos:
                pynvml.nvmlShutdown()
              self.initialized = False
  
      def get_device_count(self):
          """ Return count of Nvidia devices """
          try:
keep 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