杂项

This script displays real-time information about GPU power consumption, GPU memory usage, CPU utilization, and system memory usage. It updates every 0.1 seconds.

#!/bin/bash

# Clear the screen
clear

while true; do
    # Get GPU info
    gpu_info=$(nvidia-smi --query-gpu=power.draw,memory.used,memory.total --format=csv,noheader,nounits)
    
    # Get CPU info
    cpu_cores=$(nproc)
    cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
    used_cores=$(echo "$cpu_usage $cpu_cores" | awk '{printf "%.2f", $1 * $2 / 100}')
    
    # Get memory info
    mem_info=$(free -m | awk 'NR==2{printf "%.2f,%d,%d", $3*100/$2, $3, $2 }')

    # Process and print info
    echo "$gpu_info" | awk -v cpu="$cpu_usage" -v cores="$cpu_cores" -v used_cores="$used_cores" -v mem="$mem_info" \
    'BEGIN {FS=","; OFS=","}
     {split(mem,m,","); 
      printf "\rGPU Power: %5.2f W, GPU Memory: %5.2f%% (%d/%d MB), CPU Usage: %5.2f%% (%.2f/%d cores), System Memory: %5.2f%% (%d/%d MB)", 
      $1, $2/$3*100, $2, $3, cpu, used_cores, cores, m[1], m[2], m[3]}'

    sleep 0.1
done

Wanna use the openai api provided by microsoft azure? Follow these instructions:

Newwhitepaper_Agents2.pdf (4.1 MB)