diff --git a/gpu_load_smi/LICENSE.txt b/gpu_load_smi/LICENSE.txt new file mode 100644 index 00000000..4f761a19 --- /dev/null +++ b/gpu_load_smi/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2024 Syed Isam Hashmi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/gpu_load_smi/README.md b/gpu_load_smi/README.md new file mode 100644 index 00000000..eaf89e23 --- /dev/null +++ b/gpu_load_smi/README.md @@ -0,0 +1,33 @@ +# gpu_load_smi + +Displays information about the current state of a specific NVIDIA GPU using the `nvidia-smi` utility. + +Although it will likely be zero, you should still confirm the GPU index. +The GPU index can be fetched by using the `nvidia-smi dmon` command. +`$ nvidia-smi dmon` +``` +# gpu pwr gtemp mtemp sm mem enc dec jpg ofa mclk pclk +# Idx W C C % % % % % % MHz MHz + 0 3 51 - 0 0 0 0 0 0 405 210 +``` +The GPU index is the first column in the output. as depicted by the headers. +Identify which GPU index you want and use that as the `GPU_IDX` parameter. + + +![](gpu_load_smi.png) + +# Dependencies +- nvidia-utils (contains the `nvidia-smi` binary) +- bash + + +``` +[gpu_load_smi] +command=$SCRIPT_DIR/gpu-load +label=GPU +interval=5 +GPU_IDX=0 // [YOUR_GPU_INDEX] +``` + +If you found this useful, I'd love to hear about it. +Feel free to email me: is@mhashmi.com diff --git a/gpu_load_smi/gpu_load_smi b/gpu_load_smi/gpu_load_smi new file mode 100755 index 00000000..184b212c --- /dev/null +++ b/gpu_load_smi/gpu_load_smi @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Author: Syed Isam Hashmi +# 2024-07-30 + +gpuIdx="${GPU_IDX}" + +while read -r line; do + firstChar="${line:0:1}" + + # First couple lines and occasional lines of + # the NVIDIA-SMI output are headers that start with '#' + # + # In addition, ignore lines that arent related to this GPU device. + if [ "$firstChar" == "#" ] || [ "$firstChar" != "$gpuIdx" ]; + then + continue; + else + # I commented out unused variables + # + # Uncomment and use these lines as you wish. + line=($line) + # gpuId=${line[0]} + # pwrW=${line[1]} + gTemp=${line[2]} + # mTemp=${line[3]} + sm=${line[4]} + mem=${line[5]} + # enc=${line[6]} + # dec=${line[7]} + # jpg=${line[8]} + # ofa=${line[9]} + # mclk=${line[10]} + # pclk=${line[11]} + + # Customize to your heart's content + echo "$gTempĀ°C SM%: $sm% MEM: $mem%" + exit + fi +done < <(nvidia-smi dmon -d 1) +wait + diff --git a/gpu_load_smi/gpu_load_smi.png b/gpu_load_smi/gpu_load_smi.png new file mode 100644 index 00000000..a7405319 Binary files /dev/null and b/gpu_load_smi/gpu_load_smi.png differ diff --git a/gpu_load_smi/i3blocks.conf b/gpu_load_smi/i3blocks.conf new file mode 100644 index 00000000..03eb2278 --- /dev/null +++ b/gpu_load_smi/i3blocks.conf @@ -0,0 +1,4 @@ +[gpu_load_smi] +label=GPU +interval=5 +GPU_IDX=0