【显卡】python查看GPU(显卡)资源
生活随笔
收集整理的這篇文章主要介紹了
【显卡】python查看GPU(显卡)资源
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
nvidia-ml-py安裝
版本:375.53.1
pip install nvidia-ml-py
使用
import pynvml # 初始化模塊 pynvml.nvmlInit() # 獲取0號位GPU gpu = punvml.nvmlDeviceGeHandleByIndex(0) gpu_info = pynvml.nvmlDeviceGetMemoryInfo(gpu)獲取的gpu_info有三個字段信息,獲取方式如下
gpu_info.total # 總量 gpu_info.used # 使用量 gpu_info.free # 空余量問題
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(c_count.value)?報錯原因是這個版本支持python2,有一個地方print方法還是python2不支持python3,修改如下:
修改完就可以支持python3。
總結
以上是生活随笔為你收集整理的【显卡】python查看GPU(显卡)资源的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WPF学习笔记(三)
- 下一篇: python如何下载tushare_如何