python nvidia 显卡信息 格式数据

python nvidia 显卡信息 格式数据.

python 复制代码
def get_gpu_memory():
    result = subprocess.check_output(['nvidia-smi', '--query-gpu=pci.bus_id,memory.used,memory.total,memory.free', '--format=csv'])
    # 返回 GPU 的显存使用情况,单位为 M
    info = []
    for t in csv.DictReader(result.decode().splitlines()):
        info.append({'id':t['pci.bus_id'],
         'used':int(t[' memory.used [MiB]'].split()[0]),
         'total':int(t[' memory.total [MiB]'].split()[0]),
         'free':int(t[' memory.free [MiB]'].split()[0])})
    return info

参考

相关推荐
aqi0020 分钟前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵2 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf3 小时前
Agent 流程编排
后端·python·agent
copyer_xyf3 小时前
Agent RAG
后端·python·agent
copyer_xyf3 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf4 小时前
Agent 记忆管理
后端·python·agent
星云穿梭19 小时前
用Python写一个带图形界面的学生管理系统——完整教程
python
金銀銅鐵19 小时前
用 Pygame 实现 15 puzzle
python·数学·游戏
黄忠1 天前
大模型之LangGraph技术体系
python·llm