Last active
April 2, 2020 20:44
-
-
Save xu-ji/2f88c41362893ca926485b227f1c116a to your computer and use it in GitHub Desktop.
GPU stat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynvml.smi import nvidia_smi | |
def get_gpu_mem(nvsmi, gpu_ind): | |
mem_stats = nvsmi.DeviceQuery('memory.free, memory.total')["gpu"][gpu_ind]["fb_memory_usage"] | |
return mem_stats["total"] - mem_stats["free"] | |
nvsmi = nvidia_smi.getInstance() | |
gpu_ind = 0 | |
print(get_gpu_mem(nvsmi, gpu_ind)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment