可以使用pynvml库来查看
pynvml的安装
pip install nvidia-ml-py3
(尝试了一下,conda install
似乎行不通)
pynvml的使用
import pynvml
pynvml.nvmlInit()
# GPU的id
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
print(meminfo.used)
可以使用pynvml库来查看
pip install nvidia-ml-py3
(尝试了一下,conda install
似乎行不通)
import pynvml
pynvml.nvmlInit()
# GPU的id
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
meminfo = pynvml.nvmlDeviceGetMemoryInfo(handle)
print(meminfo.used)
本文标题:2020-03-23 python中如何查看GPU显存占用
本文链接:https://www.haomeiwen.com/subject/umhgyhtx.html
网友评论