Last week I’ve spent multiple hours migrating our mining rig from win10 to linux. So this post is a note to myself about the things I did to successfully confugure a mining rig running on linux.
Note
This doc would be useful for purely NVIDIA-based mining rigs.
Installation & dependencies
It all starts from linux distribution. In my case - ubuntu, because it’s the popular one. There are lots of distros made specifically for mining rigs, but the ones I’ve looked at are either paid via monthly subscription or closed source.
Download desktop version of ubuntu LTS 20.04 from here, write the image on USB stick and install it on a rig.
After the installation is done, run the updates:
1
| sudo apt-get update && sudo apt-get upgrade
|
and reboot:
Note
At the time of writing, Ubuntu 20.04 already has proper repositories configured for nvidia drivers. If, for some reason, they’re missing then run:
1
2
| sudo apt-add-repository ppa:graphics-drivers/ppa
sudo apt-get update
|
At this point, make sure that all your GPUs are properly plugged in - either directly or via risers. Verify that ubuntu sees all the GPUs:
Install the necessary packages such as SSH server, linux headers:
1
2
3
| sudo apt-get install linux-headers-$(uname -r) openssh-server xorg-dev cron \
build-essential dkms freeglut3 freeglut3-dev libxi-dev libxmu-dev \
nvidia-driver-450 nvidia-cuda-toolkit
|
When successful, we need to check that drivers have been installed correctly by running:
The expected output should look like this:
1
2
3
4
5
6
7
| rsi2m@rsi2m-MS-7A71:~$ lsmod | grep nvidia
nvidia_uvm 1007616 4
nvidia_drm 53248 12
nvidia_modeset 1183744 3 nvidia_drm
nvidia 19677184 1480 nvidia_uvm,nvidia_modeset
drm_kms_helper 184320 1 nvidia_drm
drm 491520 15 drm_kms_helper,nvidia_drm
|
If you’re getting the similar result, then congrats 🍾🍾🍾 all the required dependencies have been installed!
Let’s celebrate by running:
It shows lots of useful information about you GPUs, here’s mine for example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| +-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57 Driver Version: 450.57 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 105... On | 00000000:01:00.0 Off | N/A |
| 20% 65C P0 N/A / 56W | 2541MiB / 4038MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 106... On | 00000000:02:00.0 Off | N/A |
| 50% 71C P2 122W / 120W | 2558MiB / 6078MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 2 GeForce GTX 105... On | 00000000:04:00.0 Off | N/A |
| 28% 72C P0 N/A / 75W | 2540MiB / 4040MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 3 GeForce GTX 105... On | 00000000:05:00.0 Off | N/A |
| 22% 70C P0 N/A / 75W | 2540MiB / 4040MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 4 GeForce GTX 105... On | 00000000:06:00.0 Off | N/A |
| 25% 72C P0 N/A / 75W | 2540MiB / 4040MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 5 GeForce GTX 105... On | 00000000:07:00.0 Off | N/A |
| 13% 65C P0 N/A / 75W | 2540MiB / 4040MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
|
At this point, the installation is done, let’s reboot.
Overclocking
Note
Changing the fan speed, GPU core clock and GPU memory clock could damage the GPU and or shorten the life of the GPU, but so does the mining - you know what you’re doing.
Before we begin messing our GPUs, there’s one potential problem we want to solve. When running:
via SSH connection we might be greeted with the following error:
1
2
| Unable to init server: Could not connect: Connection refused
ERROR: The control display is undefined; please run `nvidia-settings --help` for usage information.
|
Don’t worry! This just means that nvidia-settings
doesn’t find any displays (and for some reason cannot run witout it).
Instal some more stuff (selecting xdm
if promted):
1
| sudo apt-get install build-essential xserver-xorg p7zip xorg-dev libgtk-3-dev xdm
|
Add the following lines to /etc/X11/xdm/Xsetup
file (create it if missing):
1
2
3
4
5
6
| export PATH=/bin:/usr/bin:/sbin
export HOME=/root
export DISPLAY=:0
xset -dpms
xset s off
xhost +
|
Add the following line to ~/.profile
file (create it if missing):
Generate NVIDIA config file:
1
| sudo nvidia-xconfig -a --allow-empty-initial-configuration --cool-bits=28 --use-display-device="DFP-0" --connected-monitor="DFP-0" --custom-edid="DFP-0:/etc/X11/dfp-edid.bin"
|
and reboot.
After these steps, nvidia-config
shouldn’t spit any errors.
Lets exercise in using nvidia-config
! Usually, all mutating commands look a bit like this:
Tip
Keep in mind, that you need to replace index_of_GPU
in the commands below with the index of desired GPU, for example - 0.
1
| nvidia-settings -a [gpu:index_of_GPU]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=fan_speed_percentage
|
To change the fan speed of the first GPU, we could run this:
1
| nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=100
|
If everything is configured correctly, then GPU fan should start spinning. You can check it by running nvidia-smi
To change the GPU core clock speed, use:
1
| nvidia-settings -a '[gpu:index_of_GPU]/GPUGraphicsClockOffset[power_state]=+or-offset'
|
Tip
Note, that power_state
depends on GPU, for 1050Ti the value will be 2, for 1060 it’s 3. Usually it’s on of these values.
So, to overclock 1060’s core by 200 MHz run:
1
| nvidia-settings -a '[GPU:0]/GPUGraphicsClockOffset[3]=150'
|
similar command is used for overclocking the memory speed:
1
| nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=670'
|
The last step would be to change the power limit of the GPU, because keeping GPUs minig at 100% power is never cost-efficient. Before doing that, let’s enabled persistence mode for nvidia-smi
:
1
| sudo nvidia-smi -pm ENABLED
|
To do that, nvidia-smi
command is used:
1
| sudo nvidia-smi -i index_of_GPU -pl new_power_limit
|
Tip
Usually it’s a good idea to set the power limit to 75-80%, you need to do the math for your specific GPU. In my case, maximum power consumed by 1050Ti is 75W, so 75% of that is 56W.
So, to set the power limit of 56W for 1050Ti run:
1
| sudo nvidia-smi -i 1 -pl 56
|
Mining software
Download gminer (version 2.19 at the time of writing) and extract it:
1
2
| wget https://github.com/PhoenixMiner-download/PhoenixMiner/releases/download/5.1b/PhoenixMiner_5.1b_Linux.zip &&
unzip PhoenixMiner_5.1b_Linux.zip
|
and to mine ETH, for example, the contents of this file PhoenixMiner_5.1b_Linux/5_Ethereum-ethermine.sh
should be changed. This is how my script looks like:
1
| ./PhoenixMiner -pool eu1.ethermine.org:4444 -wal 6a3783658d5feacb0214a2c12a698441b0936560 -worker little-one -epsw x -mode 1 -log 0 -mport 0 -etha 0 -ftime 55 -retrydelay 1 -tt 79 -tstop 89 -coin eth
|
Before going forward It’s worth replacing the relative path to a phoenix binary to the absolute one. So instead of ./PhoenixMiner
you should have /absolute/path/to/PhoenixMiner
, doing this will allow a script to work via crontab later.
One more thing
At this point, you know everything you need to start mining ETH on linux, but here’s some quality-of-life bits that make a miner’s ⛏ life a bit easier.
In order to make your mining rig more resilient, we could setup cron to start a miner on system start. In order to do that, run:
in opened file add the folowing line:
1
| @reboot /absolute/path/to/your/mining/script.sh
|
In addition to that, we should make our GPU overclocking configuration to be applied as well. To do that, either edit PhoenixMiner_5.1b_Linux/5_Ethereum-ethermine.sh
script or create a new one with the following content:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| sleep 60s
sudo nvidia-smi -pm ENABLED
sudo nvidia-smi -pl 56
CLOCK=150
MEM=670
CMD='sudo /usr/bin/nvidia-settings'
for i in {0..5}
do
${CMD} -a [gpu:${i}]/GPUPowerMizerMode=1
${CMD} -a [gpu:${i}]/GPUGraphicsClockOffset[2]=${CLOCK}
${CMD} -a [gpu:${i}]/GPUMemoryTransferRateOffset[2]=${MEM}
done
|
Tip
I’ve added a 60 second sleep in the begining, because we don’t want to start mining right at the system startup. This script sets the power limit of ALL my 6 1050Ti GPUs and applies OC conf. You probably want to change it a bit, if you have different GPUs.
And that’s it!