我是 UNIX 和 Gnu/Linux 腳本的新手,我需要幫助來建立修改 lm-sensors 輸出的腳本。
當我使用該命令時,sensors
這是當前輸出
mint@desktop:~$ sensors
amdgpu-pci-0100
Adapter: PCI adapter
vddgfx: +0.72 V
fan1: 1245 RPM (min = 0 RPM, max = 2400 RPM)
edge: +37.0°C (crit = +94.0°C, hyst = -273.1°C)
power1: 34.26 W (cap = 145.00 W)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +39.0°C (high = +85.0°C, crit = +105.0°C)
Core 0: +36.0°C (high = +85.0°C, crit = +105.0°C)
Core 1: +40.0°C (high = +85.0°C, crit = +105.0°C)
Core 2: +35.0°C (high = +85.0°C, crit = +105.0°C)
Core 3: +37.0°C (high = +85.0°C, crit = +105.0°C)
我來自 Windows,我曾經使用 HWMonitor 來即時查看使用情況和臨時資訊等內容,但很難在 Linux 上完成此任務,我的腳本想法是製作一些可以獲取感測器資訊並將友好輸出轉換為像這樣的東西:
amdgpu-pci-0100
Voltage: +0.72 V
Fans Speed: 1248 RPM ( Percentage %% )
Temperature: +36.0°C ( Percentage %% )
Power: 34.22 W ( Percentage %% )
GPU Usage: Percentage %%
VRAM Usage: 1GB / 8GB ( Percentage %% )
你能幫助我嗎?我不是詢問完整的腳本,只是詢問您可能對新手有的任何建議,這個腳本可以製作嗎?
順便說一句,我嘗試過 PSensor,但它不顯示 amdgpu 模組,而 RadeonTop 不顯示溫度和 VRAM。
答案1
對於 AMD GPU,您可以作為簡單用戶存取所有這些數據/sys/class/drm/card0/device/
你正在尋找的是/sys/class/drm/card0/device/gpu_busy_percent
它可能與card0不同(取決於你有多少GPU)
在此目錄中,您將擁有所需的一切,例如 GPU/VRAM 使用情況、溫度、張力等。
大多數檔案對於 cat 都是安全的,但是切勿 cat /sys/class/drm/card0/device/remove
,如果這樣做,只需重新啟動即可。
我強烈建議您閱讀本文,以下只是摘要:
https://dri.freedesktop.org/docs/drm/gpu/amdgpu.html#gpu-power- Thermal-controls-and-monitoring
這是可以安全識別的文件清單。
/sys/class/drm/card0/device/gpu_busy_percent
GPU 核心使用率 (%)
/sys/class/drm/card0/device/mem_busy_percent
GPU 記憶體使用率 (%)
除了 . 之外,所有帶有前綴的文件pp_
都是可讀的pp_table
。
pp_dpm_*
與 GPU 核心和記憶體時鐘相關
pp_dpm_sclk
用於 GPU 核心
pp_dpm_mclk
用於 GPU 記憶體
當前狀態用*
在該目錄下,hwmon
您將有另一個與您的硬體監視器相對應的目錄,它的名稱hwmon0
如下:
/sys/class/drm/card0/device/hwmon/hwmon0/fan*
GPU 風扇當前/最小/最大
/sys/class/drm/card0/device/hwmon/hwmon0/in*
GPU mV 和標籤
/sys/class/drm/card0/device/hwmon/hwmon0/power*
GPU 功率當前/最小/最大
/sys/class/drm/card0/device/hwmon/hwmon0/pwm*
GPU PWM 電流/最小/最大/
/sys/class/drm/card0/device/hwmon/hwmon0/temp*
GPU 溫度當前/最小/最大