from pynvml import * nvmlInit() h = nvmlDeviceGetHandleByIndex(0) info = nvmlDeviceGetMemoryInfo(h) print(f'total : {info.total}') print(f'free : {info.free}') print(f'used : {info.used}')