Home / Cryptocurrencies
This brief guide shows how to setup an ETH miner in a Docker container on a headless Linux (Debian) server using an NVIDIA GPU, as well as how to apply OC and power limiting to the GPU. For appropriate values for the GPU clocks and power limit, google it for your specific card to see what others are using. Note that I’m using an RTX 3080, lolMiner, ethermine.org and my own address for the examples.
nvidia-smi
apt install xorg
sudo nvidia-xconfig --cool-bits=31 --allow-empty-initial-configuration
lolminer/lolMiner --algo=ETHASH --pool=stratum+ssl://eu1.ethermine.org:5555 --user=0xF6403152cAd46F2224046C9B9F523d690E41Bffd
Example script:
#!/bin/bash
# Script to download and prepare lolMiner.
set -eu
ARCHIVE_DOWNLOAD_URL="https://github.com/Lolliedieb/lolMiner-releases/releases/download/1.26/lolMiner_v1.26_Lin64.tar.gz"
ARCHIVE_LOCAL_FILE="lolminer.tar.gz"
LOCAL_DIR="lolminer"
rm -rf "$LOCAL_DIR"
mkdir "$LOCAL_DIR"
wget "$ARCHIVE_DOWNLOAD_URL" -O "$ARCHIVE_LOCAL_FILE"
tar xvf "$ARCHIVE_LOCAL_FILE" -C "$LOCAL_DIR" --strip-components=1
rm -rf "$ARCHIVE_LOCAL_FILE"
These are also present in the example script below so you don’t have to run them manually, but you should run them once manually first to make sure they work regardless.
To see if they work, run the miner while changing the settings and monitor the hashrate in the miner and the power usage in nvidia-smi
.
Note that the [4]
used in some of the commands may be different for you (it’s related to the performance level AFAIK).
xinit &
nvidia-smi -i 0 -pm 1
nvidia-smi -i 0 -pl 220
(220W)DISPLAY=:0.0 nvidia-settings -c :0 -a "[gpu:0]/GPUPowerMizerMode=1"
DISPLAY=:0.0 nvidia-settings -c :0 -a "[gpu:0]/GPUMemoryTransferRateOffset[4]=1000"
(1000MHz)DISPLAY=:0.0 nvidia-settings -c :0 -a "[gpu:0]//GPUGraphicsClockOffset[4]=-200"
(-200MHz)DISPLAY=:0.0 nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=100"
(100%)/etc/cron.d/lolminer
), containing something like @reboot root /srv/lolminer/oc.sh >/dev/null
in order to run the script below.Example script:
#!/bin/bash
# Script to apply OC, power limiting etc.
set -eu
GPU_ID=0
GPU_POWER_LIMIT=220
GPU_CORE_CLOCK_OFFSET=-200
GPU_MEMORY_CLOCK_OFFSET=1000
XINIT_SLEEP=2
echo
echo "Starting X11 session in background ..."
pkill xinit || :
sleep $XINIT_SLEEP
xinit >/dev/null 2>&1 &
sleep $XINIT_SLEEP
echo
echo "Applying settings ..."
export DISPLAY=:0.0
nvidia-smi -i $GPU_ID -pm 1
nvidia-smi -i $GPU_ID -pl $GPU_POWER_LIMIT
nvidia-settings -c :0 -a "[gpu:$GPU_ID]/GPUPowerMizerMode=1"
nvidia-settings -c :0 -a "[gpu:$GPU_ID]/GPUMemoryTransferRateOffset[4]=$GPU_MEMORY_CLOCK_OFFSET"
nvidia-settings -c :0 -a "[gpu:$GPU_ID]/GPUGraphicsClockOffset[4]=$GPU_CORE_CLOCK_OFFSET"
#nvidia-settings -a "[gpu:$GPU_ID]/GPUFanControlState=1" -a "[gpu:$GPU_ID]/GPUTargetFanSpeed=100"
echo
echo "Killing the X11 session ..."
pkill xinit
sleep $XINIT_SLEEP
echo
echo "Done!"
--restart=always
will cause it to restart if it crashes as well as starting automatically on system boot.#!/bin/bash
# Script to start the miner inside a container.
set -eu
DOCKER_NAME="lolminer"
DOCKER_IMAGE="nvidia/cuda:11.2.2-base"
DOCKER_COMMAND="\
/opt/lolminer/lolMiner \
--nocolor \
--algo=ETHASH \
--pool=stratum+ssl://eu1.ethermine.org:5555 \
--user=0xF6403152cAd46F2224046C9B9F523d690E41Bffd.worker-1 \
"
DOCKER_VOLUME="$PWD/lolminer:/opt/lolminer/:ro"
docker run -d --init --gpus all -v "$DOCKER_VOLUME" --restart=unless-stopped --name="$DOCKER_NAME" "$DOCKER_IMAGE" $DOCKER_COMMAND