How To Configure Nvidia Settings For Linux Crypto Mining On Headless Ubuntu System

Before I start, here are the two most important gists:

org.conf

https://gist.github.com/joelgriffiths/42e4ac6e01f87fbdc82e535b235b81c0

My overclock script (use settings at your own risk)

https://gist.github.com/joelgriffiths/bf352892a17910d85366cf592e87b1dc

Useful Commands

These are not entirely necessary, but they might be useful.

List all the cards:

lspci -v | grep -A 2 -E "(VGA comp|3D)"
OR
nvidia-smi -L
OR (if you want a lot of detail including serial numbers for GPU 0, 1,2, and 3)
nvidia-smi -i 0,1,2,3 -q
Step 1 – Disable GUI Boot
sudo systemctl set-default multi-user
Step 2- Install X11

I normally cheat, by installing x11-apps. I think you can do xterm here without x11-apps, but who doesn’t like xeyes?

sudo apt install x11-apps
sudo apt install xterm
sudo echo "allowed_users=anybody" > /etc/X11/Xwrapper.config
Step 3 – Get the Correct Drivers
sudo add-apt-repository ppa:graphics-drivers/ppa
# Get the driver version (I think)
sudo ubuntu-drivers devices
# And install the version from the last step
sudo apt install -y nvidia-driver-[460]
Step 4 – Configure Nvida settings to allow overclocking in a headless configuration:
nvidia-xconfig -a --allow-empty-initial-configuration --cool-bits=28 --use-display-device="DFP-0" --connected-monitor="DFP-0"
Step 5 – Configure xinit so it can be run remotely

Enable xinit for ssh users by changing the Xwrapper.config to anybody (from console).

allowed_users=anybody
reboot
Step 6 – Start xinit (preferably in tmux)
tmux
xinit&
Step 7 – Lets do so Overclocking now
# List cards
nvidia-sml -L
# Enable persistence mode
nvidia-smi -pm ENABLED
# 3070
# Reduce Power for 3070's from 200W
sudo nvidia-smi -pl 130 -i 0
sudo nvidia-smi -pl 130 -i 1
sudo nvidia-smi -pl 130 -i 3
nvidia-settings -c :0 -a '[gpu:0]/GPUGraphicsClockOffset[4]=-500' -a '[gpu:0]/GPUMemoryTransferRateOffset[4]=1100'
nvidia-settings -c :0 -q '[gpu:0]/GPUGraphicsClockOffset[4]' -q '[gpu:0]/GPUMemoryTransferRateOffset[4]' --ctrl-display=:0
nvidia-settings -c :0 -a '[gpu:1]/GPUGraphicsClockOffset[4]=-500' -a '[gpu:1]/GPUMemoryTransferRateOffset[4]=1100'
nvidia-settings -c :0 -q '[gpu:1]/GPUGraphicsClockOffset[4]' -q '[gpu:1]/GPUMemoryTransferRateOffset[4]' --ctrl-display=:0
# 2080
sudo nvidia-smi -pl 155 -i 0
nvidia-settings -c :0 -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=1300'
nvidia-settings -c :0 -a '[gpu:0]/GPUGraphicsClockOffset[3]=-50'
# 1080
sudo nvidia-smi -pl 135 -i 2
nvidia-settings -c :0 -a '[gpu:2]/GPUMemoryTransferRateOffset[3]=1300'
nvidia-settings -c :0 -a '[gpu:2]/GPUGraphicsClockOffset[3]=100'
# Query to Check
nvidia-settings --query [gpu:0]/GPUPerfModes --ctrl-display=:0

How much power are you drawing:

$ nvidia-smi -q -d power

Increase the power limit for CPU 1:

Potential ERRORS

Console Only xinit

Error:

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

Solution:

Change /etc/X11/Xwrapper.config

allowed_users=anybody

ERROR: Unable to load info from any available system

If you’re running headless, make sure you specify the ctrl-display to :0.

nvidia-settings -a "[gpu:0]/GPUMemoryTransferRateOffset[3]=975" --ctrl-display=:0
Query Card Options

nvidia-settings –query [gpu:0]/GPUPerfModes –ctrl-display=:0

Some of My Overclock Settings

Useful References

https://medium.com/@coinkaner/linux-using-nvidia-gpus-for-crypto-mining-but-the-onboard-gpu-as-primary-output-for-your-display-1f4bb4073026

Leave a Reply

Your email address will not be published. Required fields are marked *