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


Python pynvml.nvmlShutdown方法代码示例

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


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

示例1: gpu_info

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [as 别名]
def gpu_info(self):
        # pip install nvidia-ml-py3
        if len(self.gpu_ids) >= 0 and torch.cuda.is_available():
            try:
                import pynvml
                pynvml.nvmlInit()
                self.config_dic['gpu_driver_version'] = pynvml.nvmlSystemGetDriverVersion()
                for gpu_id in self.gpu_ids:
                    handle = pynvml.nvmlDeviceGetHandleByIndex(gpu_id)
                    gpu_id_name = "gpu%s" % gpu_id
                    mem_info = pynvml.nvmlDeviceGetMemoryInfo(handle)
                    gpu_utilize = pynvml.nvmlDeviceGetUtilizationRates(handle)
                    self.config_dic['%s_device_name' % gpu_id_name] = pynvml.nvmlDeviceGetName(handle)
                    self.config_dic['%s_mem_total' % gpu_id_name] = gpu_mem_total = round(mem_info.total / 1024 ** 3, 2)
                    self.config_dic['%s_mem_used' % gpu_id_name] = gpu_mem_used = round(mem_info.used / 1024 ** 3, 2)
                    # self.config_dic['%s_mem_free' % gpu_id_name] = gpu_mem_free = mem_info.free // 1024 ** 2
                    self.config_dic['%s_mem_percent' % gpu_id_name] = round((gpu_mem_used / gpu_mem_total) * 100, 1)
                    self._set_dict_smooth('%s_utilize_gpu' % gpu_id_name, gpu_utilize.gpu, 0.8)
                    # self.config_dic['%s_utilize_gpu' % gpu_id_name] = gpu_utilize.gpu
                    # self.config_dic['%s_utilize_memory' % gpu_id_name] = gpu_utilize.memory

                pynvml.nvmlShutdown()
            except Exception as e:
                print(e) 
开发者ID:dingguanglei,项目名称:jdit,代码行数:26,代码来源:super.py

示例2: _shutdown_nvml

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [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

示例3: pynvml_context

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [as 别名]
def pynvml_context():
    pynvml.nvmlInit()
    yield
    pynvml.nvmlShutdown() 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:6,代码来源:gpu_interface.py

示例4: run_logging_loop

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [as 别名]
def run_logging_loop(async_task, async_loop):
    asyncio.set_event_loop(async_loop)
    pynvml.nvmlInit()
    logger = _logger()
    logger.info("Driver Version: {}".format(nativestr(pynvml.nvmlSystemGetDriverVersion())))
    async_loop.run_until_complete(async_task)
    logger.info("Shutting down driver")
    pynvml.nvmlShutdown() 
开发者ID:msalvaris,项目名称:gpu_monitor,代码行数:10,代码来源:gpu_interface.py

示例5: _shutdown

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [as 别名]
def _shutdown(self):
        """ Shutdown pynvml if it was the library used for obtaining stats and set
        :attr:`_initialized` back to ``False``. """
        if self._initialized:
            self._handles = list()
            if not IS_MACOS and not self._is_plaidml:
                pynvml.nvmlShutdown()
            self._initialized = False 
开发者ID:deepfakes,项目名称:faceswap,代码行数:10,代码来源:gpu_stats.py

示例6: _monitor

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [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

示例7: end

# 需要导入模块: import pynvml [as 别名]
# 或者: from pynvml import nvmlShutdown [as 别名]
def end(self, session):
        """Called at the end of a session.

        Arguments:
            session (tf.Session):
                The `session` argument can be used in case the hook wants to run final ops,
                such as saving a last checkpoint.
        """
        # Shutdown the NVML interface.
        nvml.nvmlShutdown() 
开发者ID:mdangschat,项目名称:ctc-asr,代码行数:12,代码来源:hooks.py


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