def get_vram_free(): """ Return free and total VRAM on card with most VRAM free""" stats = GPUStats() vram = stats.get_card_most_free() logger.verbose("Using device %s with %sMB free of %sMB", vram["device"], int(vram["free"]), int(vram["total"])) return int(vram["card_id"]), int(vram["free"]), int(vram["total"])
def _set_parallel_processing(self, multiprocess): """ Set whether to run detect, align, and mask together or separately """ if not multiprocess: logger.debug("Parallel processing disabled by cli.") return False gpu_stats = GPUStats() if gpu_stats.device_count == 0: logger.debug("No GPU detected. Enabling parallel processing.") return True if get_backend() == "amd": logger.debug("Parallel processing disabled by amd") return False stats = gpu_stats.get_card_most_free() vram_free = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], vram_free, int(stats["total"])) if vram_free <= self._total_vram_required: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def set_parallel_processing(self): """ Set whether to run detect and align together or seperately """ detector_vram = self.detector.vram aligner_vram = self.aligner.vram gpu_stats = GPUStats() if (detector_vram == 0 or aligner_vram == 0 or gpu_stats.device_count == 0): return True if hasattr(self.args, "multiprocess") and not self.args.multiprocess: print("\nNB: Parallel processing disabled.\nYou may get faster " "extraction speeds by enabling it with the -mp switch\n") return False required_vram = detector_vram + aligner_vram + 320 # 320MB buffer stats = gpu_stats.get_card_most_free() free_vram = int(stats["free"]) if self.args.verbose: print("{} - {}MB free of {}MB".format(stats["device"], free_vram, int(stats["total"]))) if free_vram <= required_vram: if self.args.verbose: print("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def get_vram_free(): """ Return total free VRAM on largest card """ stats = GPUStats() vram = stats.get_card_most_free() logger.verbose("Using device %s with %sMB free of %sMB", vram["device"], int(vram["free"]), int(vram["total"])) return int(vram["free"])
def set_parallel_processing(self): """ Set whether to run detect and align together or separately """ detector_vram = self.detector.vram aligner_vram = self.aligner.vram gpu_stats = GPUStats() if (detector_vram == 0 or aligner_vram == 0 or gpu_stats.device_count == 0): logger.debug( "At least one of aligner or detector have no VRAM requirement. " "Enabling parallel processing.") return True if hasattr(self.args, "multiprocess") and not self.args.multiprocess: logger.info("NB: Parallel processing disabled.You may get faster " "extraction speeds by enabling it with the -mp switch") return False required_vram = detector_vram + aligner_vram + 320 # 320MB buffer stats = gpu_stats.get_card_most_free() free_vram = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], free_vram, int(stats["total"])) if free_vram <= required_vram: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def set_parallel_processing(self, multiprocess): """ Set whether to run detect and align together or separately """ detector_vram = self.detector.vram aligner_vram = self.aligner.vram gpu_stats = GPUStats() if detector_vram == 0 or aligner_vram == 0 or gpu_stats.device_count == 0: logger.debug("At least one of aligner or detector have no VRAM requirement. " "Enabling parallel processing.") return True if not multiprocess: logger.info("NB: Parallel processing disabled.You may get faster " "extraction speeds by enabling it with the -mp switch") return False required_vram = detector_vram + aligner_vram + 320 # 320MB buffer stats = gpu_stats.get_card_most_free() free_vram = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], free_vram, int(stats["total"])) if free_vram <= required_vram: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def _set_parallel_processing(self, multiprocess): """ Set whether to run detect and align together or separately """ if self._detector.vram == 0 or self._aligner.vram == 0: logger.debug( "At least one of aligner or detector have no VRAM requirement. " "Enabling parallel processing.") return True if not multiprocess: logger.debug("Parallel processing disabled by cli.") return False gpu_stats = GPUStats() if gpu_stats.device_count == 0: logger.debug("No GPU detected. Enabling parallel processing.") return True if get_backend() == "amd": logger.debug("Parallel processing discabled by amd") return False vram_required = self._detector.vram + self._aligner.vram + self._vram_buffer stats = gpu_stats.get_card_most_free() vram_free = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], vram_free, int(stats["total"])) if vram_free <= vram_required: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def set_parallel_processing(self, multiprocess): """ Set whether to run detect and align together or separately """ detector_vram = self.detector.vram aligner_vram = self.aligner.vram if detector_vram == 0 or aligner_vram == 0: logger.debug("At least one of aligner or detector have no VRAM requirement. " "Enabling parallel processing.") return True gpu_stats = GPUStats() if gpu_stats.device_count == 0: logger.debug("No GPU detected. Enabling parallel processing.") return True if not multiprocess: logger.debug("Parallel processing disabled by cli.") return False required_vram = detector_vram + aligner_vram + 320 # 320MB buffer stats = gpu_stats.get_card_most_free() free_vram = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], free_vram, int(stats["total"])) if free_vram <= required_vram: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def get_vram_free(self): """ Return free and total VRAM on card with most VRAM free""" stats = GPUStats() vram = stats.get_card_most_free() if self.verbose: print("Using device {} with {}MB free of {}MB".format( vram["device"], int(vram["free"]), int(vram["total"]))) return int(vram["card_id"]), int(vram["free"]), int(vram["total"])
def get_vram_free(self): """ Return total free VRAM on largest card """ stats = GPUStats() vram = stats.get_card_most_free() if self.verbose: print("Using device {} with {}MB free of {}MB".format( vram["device"], int(vram["free"]), int(vram["total"]))) return int(vram["free"])
def get_vram_free(): """ Return free and total VRAM on card with most VRAM free""" stats = GPUStats() vram = stats.get_card_most_free() logger.verbose("Using device %s with %sMB free of %sMB", vram["device"], int(vram["free"]), int(vram["total"])) return int(vram["card_id"]), int(vram["free"]), int(vram["total"])
def set_parallel_processing(self, multiprocess): """ Set whether to run detect and align together or separately """ detector_vram = self.detector.vram aligner_vram = self.aligner.vram if detector_vram == 0 or aligner_vram == 0: logger.debug( "At least one of aligner or detector have no VRAM requirement. " "Enabling parallel processing.") return True if not multiprocess: logger.debug("Parallel processing disabled by cli.") return False gpu_stats = GPUStats() if gpu_stats.is_plaidml and (not self.detector.supports_plaidml or not self.aligner.supports_plaidml): logger.debug( "At least one of aligner or detector does not support plaidML. " "Enabling parallel processing.") return True if not gpu_stats.is_plaidml and ( (self.detector.supports_plaidml and aligner_vram != 0) or (self.aligner.supports_plaidml and detector_vram != 0)): logger.warning( "Keras + non-Keras aligner/detector combination does not support " "parallel processing. Switching to serial.") return False if self.detector.supports_plaidml and self.aligner.supports_plaidml: logger.debug( "Both aligner and detector support plaidML. Disabling parallel " "processing.") return False if gpu_stats.device_count == 0: logger.debug("No GPU detected. Enabling parallel processing.") return True required_vram = detector_vram + aligner_vram + 320 # 320MB buffer stats = gpu_stats.get_card_most_free() free_vram = int(stats["free"]) logger.verbose("%s - %sMB free of %sMB", stats["device"], free_vram, int(stats["total"])) if free_vram <= required_vram: logger.warning("Not enough free VRAM for parallel processing. " "Switching to serial") return False return True
def _get_vram_stats(): """ Obtain statistics on available VRAM and subtract a constant buffer from available vram. Returns ------- dict Statistics on available VRAM """ vram_buffer = 256 # Leave a buffer for VRAM allocation gpu_stats = GPUStats() stats = gpu_stats.get_card_most_free() retval = dict(count=gpu_stats.device_count, device=stats["device"], vram_free=int(stats["free"] - vram_buffer), vram_total=int(stats["total"])) logger.debug(retval) return retval