当前位置: 首页>>代码示例>>Python>>正文


Python pynvml.NVMLError方法代码示例

本文整理汇总了Python中pynvml.NVMLError方法的典型用法代码示例。如果您正苦于以下问题:Python pynvml.NVMLError方法的具体用法?Python pynvml.NVMLError怎么用?Python pynvml.NVMLError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynvml的用法示例。


在下文中一共展示了pynvml.NVMLError方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_driver

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _get_driver(self):
        """ Obtain and return the installed driver version for the system's GPUs.

        Returns
        -------
        str
            The currently installed GPU driver version
        """
        if self._is_plaidml:
            driver = self._plaid.drivers
        elif IS_MACOS:
            driver = pynvx.cudaSystemGetDriverVersion(ignore=True)
        else:
            try:
                driver = pynvml.nvmlSystemGetDriverVersion().decode("utf-8")
            except pynvml.NVMLError:
                driver = "No Nvidia driver found"
        self._log("debug", "GPU Driver: {}".format(driver))
        return driver 
开发者ID:deepfakes,项目名称:faceswap,代码行数:21,代码来源:gpu_stats.py

示例2: _init_nvml

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _init_nvml(self):
        if self._load_nvidia_lib() == -1:
            return -1

        try:
            global pynvml
            import pip
            pip.main(['install', '--quiet', 'nvidia-ml-py'])
            import pynvml as pynvml
            pynvml.nvmlInit()
            return 0
        except pynvml.NVMLError, err:
            logger.debug('Failed to initialize NVML: ', err)
            return -1 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:16,代码来源:gpu_host_crawler.py

示例3: _shutdown_nvml

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _shutdown_nvml(self):
        try:
            pynvml.nvmlShutdown()
        except pynvml.NVMLError, err:
            logger.debug('Failed to shutdown NVML: ', err) 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:7,代码来源:gpu_host_crawler.py

示例4: _get_container_id

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _get_container_id(self, gpuhandle):
        cont_ids = []
        pids = []
        try:
            proc_objs = pynvml.nvmlDeviceGetComputeRunningProcesses(gpuhandle)
            if not proc_objs:
                return ['NA.NA']
            for proc_obj in proc_objs:
                pids.append(proc_obj.pid)
            for pid in pids:
                cont_ids.append(self._get_containerid_from_pid(pid))
            return cont_ids
        except pynvml.NVMLError, err:
            logger.debug('Failed to get pid on gpu: ', err) 
开发者ID:cloudviz,项目名称:agentless-system-crawler,代码行数:16,代码来源:gpu_host_crawler.py

示例5: __exit__

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def __exit__(self, exception_type, exception_value, traceback):
        # Do nothing if the exception is not from pynvml or there is no exception
        if traceback is None:
            return False
        if not issubclass(exception_type, pynvml.NVMLError):
            return False

        # Suppress pynvml exceptions so we can continue
        if self.name in NvmlCall.previously_printed_errors:
            return True
        NvmlCall.previously_printed_errors.add(self.name)
        self.log.warning("Unable to execute NVML function: %s: %s", self.name, exception_value)
        return True 
开发者ID:DataDog,项目名称:integrations-extras,代码行数:15,代码来源:nvml.py

示例6: mem_used_for

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def mem_used_for(device_handle):
    """Get GPU device memory consumption in percent"""
    try:
        return pynvml.nvmlDeviceGetMemoryInfo(device_handle).used
    except pynvml.NVMLError:
        return None 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:8,代码来源:gpu_interface.py

示例7: mem_used_percent_for

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def mem_used_percent_for(device_handle):
    """Get GPU device memory consumption in percent"""
    try:
        memory_info = pynvml.nvmlDeviceGetMemoryInfo(device_handle)
        return memory_info.used * 100.0 / memory_info.total
    except pynvml.NVMLError:
        return None 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:9,代码来源:gpu_interface.py

示例8: utilization_for

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def utilization_for(device_handle):
    """Get GPU device consumption in percent
        Percent of time over the past sample period during which one or more kernels was executing on the GPU.
    """
    try:
        return pynvml.nvmlDeviceGetUtilizationRates(device_handle).gpu
    except pynvml.NVMLError:
        return None 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:10,代码来源:gpu_interface.py

示例9: mem_utilization_for

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def mem_utilization_for(device_handle):
    """
        Percent of time over the past sample period during which global (device) memory was being read or written.
    """
    try:
        return pynvml.nvmlDeviceGetUtilizationRates(device_handle).memory
    except pynvml.NVMLError:
        return None 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:10,代码来源:gpu_interface.py

示例10: power_for

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def power_for(device_handle):
    try:
        return pynvml.nvmlDeviceGetPowerUsage(device_handle)
    except pynvml.NVMLError:
        return None 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:7,代码来源:gpu_interface.py

示例11: _get_device_count

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _get_device_count(self):
        """ Detect the number of GPUs attached to the system and allocate to
        :attr:`_device_count`. """
        if self._is_plaidml:
            self._device_count = self._plaid.device_count
        elif IS_MACOS:
            self._device_count = pynvx.cudaDeviceGetCount(ignore=True)
        else:
            try:
                self._device_count = pynvml.nvmlDeviceGetCount()
            except pynvml.NVMLError:
                self._device_count = 0
        self._log("debug", "GPU Device count: {}".format(self._device_count)) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:15,代码来源:gpu_stats.py

示例12: can_log_gpu_resources

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def can_log_gpu_resources():
    if pynvml is None:
        return False

    try:
        pynvml.nvmlInit()
        return True
    except pynvml.NVMLError:
        return False 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:11,代码来源:gpu_processor.py

示例13: get_gpu_metrics

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def get_gpu_metrics() -> List:
    try:
        pynvml.nvmlInit()
        device_count = pynvml.nvmlDeviceGetCount()
        results = []

        for i in range(device_count):
            handle = pynvml.nvmlDeviceGetHandleByIndex(i)
            results += metrics_dict_to_list(query_gpu(handle))
        return results
    except pynvml.NVMLError:
        logger.debug("Failed to collect gpu resources", exc_info=True)
        return [] 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:15,代码来源:gpu_processor.py

示例14: _monitor

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import NVMLError [as 别名]
def _monitor(self):
        pynvml.nvmlInit()
        self._find_gpu()
        current_sample = []
        while not self.should_stop:
            used_cpu = None
            used_cpumem = None
            used_gpu = None
            used_gpumem = None
            
            cpu_process = psutil.Process(self.pid)
            used_cpu = cpu_process.cpu_percent() / psutil.cpu_count() # CPU utilization in %
            used_cpumem = cpu_process.memory_info().rss // (1024*1024) # Memory use in MB

            gpu_processes = pynvml.nvmlDeviceGetComputeRunningProcesses(self.gpu)
            for gpu_process in gpu_processes:
                if gpu_process.pid == self.pid:
                    used_gpumem = gpu_process.usedGpuMemory // (1024*1024) # GPU memory use in MB
                    break

            if self.accounting_enabled:
                try:
                    stats = pynvml.nvmlDeviceGetAccountingStats(self.gpu, self.pid)
                    used_gpu = stats.gpuUtilization
                except pynvml.NVMLError: # NVMLError_NotFound
                    pass

            if not used_gpu:
                util = pynvml.nvmlDeviceGetUtilizationRates(self.gpu)
                used_gpu = util.gpu / len(gpu_processes) # Approximate based on number of processes

            current_sample.append((used_cpu, used_cpumem, used_gpu, used_gpumem))

            time.sleep(self.sampling_rate)

        self.stats.append([round(sum(x) / len(x)) for x in zip(*current_sample)])
        pynvml.nvmlShutdown() 
开发者ID:vlimant,项目名称:mpi_learn,代码行数:39,代码来源:monitor.py


注:本文中的pynvml.NVMLError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。