Overclocking multiple headless Nvidia GPU for CUDA Cryptocurrency mining on Linux

Setup

$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
02:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
03:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
04:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
06:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
07:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)

6x Gigabyte GTX 1070 G1 Gaming (7.93 GB VRAM) pool mining Ethereum.

Steps

Firstly we will have to one-time initialize /etc/X11/xorg.conf by using Nvidia's xconfig tool including a cool-bits value of 28.

# nvidia-xconfig --allow-empty-initial-configuration --enable-all-gpus --cool-bits=28

Afterwards, we can start a Xorg server headlessly as Nvidia's setting tool requires it to be up.

# X :0 & # display :0

Since I am running multiple cards, I would require a loop to go through all of it. Currently these values works best for the cards I used.

  • -200 core clock
  • +1200 memory clock
# export DISPLAY=:0
# IFS=$'\n'
# for gpu in $(nvidia-smi -L); do
	id=$(echo ${gpu} | sed -e 's/GPU //g' -e 's/:.*//g')
	nvidia-settings -a [gpu:${id}]/GPUPowerMizerMode=1 -a [gpu:${id}]/GPUGraphicsClockOffset[3]=-200 -a [gpu:${id}]/GPUMemoryTransferRateOffset[3]=1200
done

As a final step, I would apply a -40 max watts undervolt as root.

# nvidia-smi -pl 140

Optionally, since we do not need the Xorg server to be running anymore, we can kill it

# killall Xorg

These configuration alone increased ~5MH/s per card, resulting in a 25-30MH/s overall increase!

Automated bash script

#!/usr/bin/env bash
sudo nvidia-smi -pl 140
sudo X :0 &
sleep 5
export DISPLAY=:0
IFS=$'\n'
for gpu in $(nvidia-smi -L); do
	id=$(echo ${gpu} | sed -e 's/GPU //g' -e 's/:.*//g')
	sudo nvidia-settings -a [gpu:${id}]/GPUPowerMizerMode=1 -a [gpu:${id}]/GPUGraphicsClockOffset[3]=-200 -a [gpu:${id}]/GPUMemoryTransferRateOffset[3]=1200
done
sudo killall Xorg
sudo systemctl start ethminer # or your own command to start your own miner