當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。