简体   繁体   English

有没有办法在 Windows 上使用 python 获取 Intel 的集成 gpu 用法?

[英]Is there a way to get Intel's integrated gpu usage using python on Windows?

I need to get gpu usage from intel's integrated gpu using python on Windows is there a way to pull this off?, i don't mind having to use modules.我需要在 Windows 上使用 python 从英特尔的集成 gpu 获得 gpu 的使用,有没有办法解决这个问题?我不介意必须使用模块。

As suggested in the third comment, you can extract information from Windows Power Shell with the subprocess python package.正如第三条评论中所建议的,您可以使用子流程python package 从Windows Power Shell中提取信息。

import subprocess as sp

# raw strings avoid unicode encoding errors
gpu_mem_cmd = r'(((Get-Counter "\GPU Process Memory(*)\Local Usage").CounterSamples | where CookedValue).CookedValue | measure -sum).sum'
gpu_usage_cmd = r'(((Get-Counter "\GPU Engine(*engtype_3D)\Utilization Percentage").CounterSamples | where CookedValue).CookedValue | measure -sum).sum'

def run_command(command):
    val = sp.run(['powershell', '-Command', command], capture_output=True).stdout.decode("ascii")

    return float(val.strip().replace(',', '.'))

print()
print(" GPU Info ".center(80, '='))
print(f"GPU Memory Usage: {round(run_command(gpu_mem_cmd)/1e6,1):<6} MB")
print(f"GPU Load :        {round(run_command(gpu_usage_cmd),2):<6} %")

The output should be: output 应该是:

=================================== GPU Info ===================================
GPU Memory Usage: 520.1  MB
GPU Load :        2.0 %

Each command is quite slow, every GPU information that you want to retrieve takes approximately 1.5s .每条命令都比较慢,每GPU条信息要取回大约需要1.5s

Hope this can be helpful for you:)希望这对你有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Intel oneAPI DPC++ 编译器将 OpenMP 卸载到 NVIDIA GPU - OpenMP offloading with Intel oneAPI DPC++ compiler to NVIDIA GPU 使用 intel_pstate 时如何设置特定的 cpu 频率 - How to set specific cpu frequency when using intel_pstate 无法在 stackdriver Monitoring for windows 中查看内存使用情况 - Unable to view memory usage in stackdriver Monitoring for windows 有没有最好的方法将数据从雪花获取到 s3 - Is there a best way to get data from snowflake to s3 有没有办法查看前几周 cloudshell 的使用情况? - Is there a way to view the usage of cloudshell for previous weeks? 使用 S3AsyncClient 从 AWS Java SDK 2 中的 GetObjectResponse 获取 S3Object InputStream? - Get an S3Object InputStream from a GetObjectResponse in AWS Java SDK 2 Using S3AsyncClient? AMD 架构上是否有与 Intel 的 MSR_SMI_COUNT 等效的寄存器? - Is there an equivalent register to Intel's MSR_SMI_COUNT on AMD architecture? 如何在我的 python 代码中启用 Intel Extension for Pytorch(IPEX)? - How to enable Intel Extension for Pytorch(IPEX) in my python code? 如何在英特尔 RAPL 焦点设备上获取功率读数? - How to get power reading on an Intel RAPL focal appliance? 使用 Vertex AI Pipelines 通过 GPU 运行自定义 Docker 容器 - 如何安装 NVIDIA 驱动程序? - Running custom Docker container with GPU using Vertex AI Pipelines - how to install NVIDIA driver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM