def test_1_visible_devices(): if nvml.device_get_count() < 1: pytest.skip("No GPUs available") os.environ["CUDA_VISIBLE_DEVICES"] = "0" output = nvml.one_time() h = nvml._pynvml_handles() assert output["memory-total"] == pynvml.nvmlDeviceGetMemoryInfo(h).total
def test_one_time(): if nvml.device_get_count() < 1: pytest.skip("No GPUs available") output = nvml.one_time() assert "memory-total" in output assert "name" in output assert len(output["name"]) > 0
def __init__(self, n=10000): self.proc = psutil.Process() self.time = deque(maxlen=n) self.cpu = deque(maxlen=n) self.memory = deque(maxlen=n) self.count = 0 self.quantities = { "cpu": self.cpu, "memory": self.memory, "time": self.time } try: ioc = psutil.net_io_counters() except Exception: self._collect_net_io_counters = False else: self.last_time = time() self.read_bytes = deque(maxlen=n) self.write_bytes = deque(maxlen=n) self.quantities["read_bytes"] = self.read_bytes self.quantities["write_bytes"] = self.write_bytes self._last_io_counters = ioc self._collect_net_io_counters = True try: disk_ioc = psutil.disk_io_counters() except Exception: self._collect_disk_io_counters = False else: if disk_ioc is None: # diskless machine self._collect_disk_io_counters = False else: self.last_time_disk = time() self.read_bytes_disk = deque(maxlen=n) self.write_bytes_disk = deque(maxlen=n) self.quantities["read_bytes_disk"] = self.read_bytes_disk self.quantities["write_bytes_disk"] = self.write_bytes_disk self._last_disk_io_counters = disk_ioc self._collect_disk_io_counters = True if not WINDOWS: self.num_fds = deque(maxlen=n) self.quantities["num_fds"] = self.num_fds if nvml.device_get_count() > 0: gpu_extra = nvml.one_time() self.gpu_name = gpu_extra["name"] self.gpu_memory_total = gpu_extra["memory-total"] self.gpu_utilization = deque(maxlen=n) self.gpu_memory_used = deque(maxlen=n) self.quantities["gpu_utilization"] = self.gpu_utilization self.quantities["gpu_memory_used"] = self.gpu_memory_used self.update()
def test_1_visible_devices(): os.environ["CUDA_VISIBLE_DEVICES"] = "0" output = nvml.one_time() h = nvml._pynvml_handles() assert output["memory-total"] == pynvml.nvmlDeviceGetMemoryInfo(h).total
def test_one_time(): output = nvml.one_time() assert "memory-total" in output assert "name" in output assert len(output["name"]) > 0