import pynvml
import time
# Initialize NVML
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0) # Assuming you have only one GPU
while True:
# Get the memory information for the GPU
memory_info = pynvml.nvmlDeviceGetMemoryInfo(handle)
used_vram = memory_info.used // (1024 ** 2) # Convert bytes to MB
total_vram = memory_info.total // (1024 ** 2) # Convert bytes to MB
vram_usage_percentage = round((used_vram / total_vram) * 100)
print(f'vram usage: {vram_usage_percentage}%')
time.sleep(5)
import pynvml
import time
# Initialize NVML
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0) # Assuming you have only one GPU
while True:
# Get the memory information for the GPU
memory_info = pynvml.nvmlDeviceGetMemoryInfo(handle)
used_vram = memory_info.used // (1024 ** 2) # Convert bytes to MB
total_vram = memory_info.total // (1024 ** 2) # Convert bytes to MB
vram_usage_percentage = round((used_vram / total_vram) * 100)
print(f'vram usage: {vram_usage_percentage}%')
time.sleep(5)