GPU 状态检测 & Burn

目录

Linux下Gpu查看

lspci指令

Nvidia自带工具

基于该工具获取GPU内存使用率、GPU占用率:

现成的软件工具

C++开源救命

检测gpu状态(python开源)

 pytorch

opengl/vulkan

Others


Linux下Gpu查看

lspci指令

https://linux.die.net/man/8/lspci

lspci is a utility for displaying information about PCI buses in the system and devices connected to them.

lspci | grep -i vga

使用nvidia GPU可以: lspci | grep -i nvidia

Nvidia自带工具

Nvidia自带一个命令行工具可以查看显存的使用情况:

 NVIDIA System Management Interface | NVIDIA Developer

watch -n 0.1 nvidia-smi   //0.1s更新一次

https://developer.download.nvidia.com/compute/DCGM/docs/nvidia-smi-367.38.pdf


基于该工具获取GPU内存使用率、GPU占用率:

import os

def getUsageRate(gpuId):
    bashCmd='nvidia-smi -q -i '+ str(gpuId) + ' -d UTILIZATION |grep Gpu'
    status = os.popen(bashCmd).read().replace(' ','')
    #print(status)
    gpuUsageRate = float(status[status.find(':') + 1 : status.find('%')])
    print('gpuUsageRate=', gpuUsageRate)
    return gpuUsageRate


def getMemoryRate(gpuId):
    bashCmd='nvidia-smi -q -i '+str(gpuId)+' -d UTILIZATION |grep Memory'
    memoryStatus = os.popen(bashCmd).read().replace(' ','')
    #print(memoryStatus)
    memoryUsageRate = float(memoryStatus[memoryStatus.find(':') + 1 : memoryStatus.find('%')])
    print('memoryUsageRate=', memoryUsageRate)


if __name__=="__main__":
    getUsageRate(2)
    getMemoryRate(2)

现成的软件工具

UNIGINE Benchmarks

GpuTest - Cross-Platform GPU Stress Test and OpenGL Benchmark for Windows, Linux and OS X | Geeks3D.com

C++开源救命

https://github.com/wilicc/gpu-burn

// runLength : unit is seconds, the time of buring GPU.
// useDoubles: true: use double type as array element type.
// useBytes:  -80: 程序会占用GPU当前的剩余memory的80%;
//             1300:程序会占用GPU的1300M byte.
template<class T> void launch(int runLength, bool useDoubles, bool useTensorCores, ssize_t useBytes)

Note: 如果有三个GPU,程序会启动三个进程用于burn 每个GPU, 主进程通过pipe与它们通信;

检测gpu状态(python开源)

https://github.com/wookayin/gpustathttps://github.com/wookayin/gpustat

 
pytorch

https://pytorch.org/ 

opengl/vulkan

Others

Running Python script on GPU. - GeeksforGeekshttps://www.geeksforgeeks.org/running-python-script-on-gpu/

https://medium.com/geekculture/executing-a-python-script-on-gpu-using-cuda-and-numba-in-windows-10-1a1b10c29c9https://medium.com/geekculture/executing-a-python-script-on-gpu-using-cuda-and-numba-in-windows-10-1a1b10c29c9

     设置使用哪个gpu: (好像不work)如何指定程序在某个GPU上运行 python_Diana_Z的博客-CSDN博客_python在gpu上运行https://blog.csdn.net/Diana_Z/article/details/89449186

 Is a GPU available? – Machine Learning on GPUhttps://hsf-training.github.io/hsf-training-ml-gpu-webpage/02-whichgpu/index.html

https://www.cyberciti.biz/open-source/command-line-hacks/linux-gpu-monitoring-and-diagnostic-commands/

https://www.mdpi.com/2079-3197/8/1/4/htm

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

First Snowflakes

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值