Skip to content

Instantly share code, notes, and snippets.

@cdarken
Last active June 14, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdarken/ec27b06d6b7f7d95f8deee7fee7d78cd to your computer and use it in GitHub Desktop.
Save cdarken/ec27b06d6b7f7d95f8deee7fee7d78cd to your computer and use it in GitHub Desktop.
Setting clocks and voltages for Polaris cards
#!/bin/bash
FAN_SPEED=30
RESET="n"
[[ "$2" == "print" ]] && PRINT_ONLY="y" || PRINT_ONLY=
if [ "$1" == "XMR1" ]; then
MEM="m 2 2100 850"
GPU_1_G="s 3 1125 825"
GPU_2_G="s 3 1125 812"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "XMR2" ]; then
MEM="m 2 1900 800"
GPU_1_G="s 3 1130 825"
GPU_2_G="s 3 1130 812"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "BEAM" ]; then
MEM="m 2 1300 750"
#MEM="m 2 1750 800"
GPU_1_G="s 3 1130 825"
GPU_2_G="s 3 1150 825"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "BEAM1" ]; then
MEM="m 2 1000 750"
GPU_1_G="s 3 1150 837"
GPU_2_G="s 3 1170 837"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "BEAM2" ]; then
GPU_1_G="s 3 1150 837"
GPU_2_G="s 3 1170 837"
MEM="m 2 1350 750"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "BEAM3" ]; then
MEM="m 2 1300 750"
GPU_1_G="s 3 1200 887"
GPU_2_G="s 3 1215 887"
GPU_1_M=$MEM
GPU_2_M=$MEM
elif [ "$1" == "reset" ]; then
RESET="y"
else
echo "No preset specified"
exit
fi
for GPU in {1..2}; do
GPU_SETTING_VAR="GPU_${GPU}_G"
GPU_SETTING_VAL=${!GPU_SETTING_VAR}
MEM_SETTING_VAR="GPU_${GPU}_M"
MEM_SETTING_VAL=${!MEM_SETTING_VAR}
echo "GPU${GPU}: Gpu: $GPU_SETTING_VAL Mem: $MEM_SETTING_VAL"
if [ ! -z "$PRINT_ONLY" ]; then
continue
fi
sudo bash -c "echo r > /sys/class/drm/card${GPU}/device/pp_od_clk_voltage"
if [ "$RESET" == "y" ]; then
echo "Resetting GPU${GPU}"
sudo bash -c "echo auto > /sys/class/drm/card${GPU}/device/power_dpm_force_performance_level"
sudo bash -c "echo c > /sys/class/drm/card${GPU}/device/pp_od_clk_voltage"
continue
fi
sudo bash -c "echo manual > /sys/class/drm/card${GPU}/device/power_dpm_force_performance_level"
sudo bash -c "echo ${GPU_SETTING_VAL} > /sys/class/drm/card${GPU}/device/pp_od_clk_voltage"
if [ ! -z "$MEM_SETTING_VAL" ]; then
sudo bash -c "echo ${MEM_SETTING_VAL} > /sys/class/drm/card${GPU}/device/pp_od_clk_voltage"
fi
sudo bash -c "echo c > /sys/class/drm/card${GPU}/device/pp_od_clk_voltage"
# pin gpu clock speed
sudo bash -c "echo \"0 1 2 3\" > /sys/class/drm/card${GPU}/device/pp_dpm_sclk"
sudo bash -c "echo \"0 1 2\" > /sys/class/drm/card${GPU}/device/pp_dpm_mclk"
done
if [ ! -z "$PRINT_ONLY" ]
then
exit
fi
sudo amdcovc fanspeed:0-1=$FAN_SPEED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment