Hi,
You can try the below!
# pip install pynvml
from pynvml import * # too lazy, not a good thing
def show_gpu(msg):
    nvmlInit()
    handle = nvmlDeviceGetHandleByIndex(0)
    info = nvmlDeviceGetMemoryInfo(handle)
    total = info.total
    free = info.free
    used = info.used
    pct = used/total;
    print('\n' + msg, f'Used {100*pct:2.1f}% ({used} out of {total} {free}')