Skip to content

Instantly share code, notes, and snippets.

@stralex7
Last active July 30, 2021 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stralex7/4e86d738beeb6c5d06fd1f1651644609 to your computer and use it in GitHub Desktop.
Save stralex7/4e86d738beeb6c5d06fd1f1651644609 to your computer and use it in GitHub Desktop.
CERBERUS-GTX1070TI-A8G ASUS Cerberus GTX 1070 Ti for ether mining using Ubuntu 17.10

Recently I got my hands on this fairly new card at a "decent" price. These notes are mainly for myself, but comments are welcome.

Hardware specs:

  • H81 Pro BTC R2.0
  • Intel(R) Celeron(R) CPU G1840 @ 2.80GHz
  • 4Gb RAM

Update1

I switched to ubuntu 18.04.1 with out any problem, to use lastest stable version of etherminer 0.15 CUDA-9.2 is required. Package names are different for driver version 396 to get the package name use:

/opt/miner# ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001B81sv00001043sd00008599bc03sc00i00
vendor   : NVIDIA Corporation
model    : GP104 [GeForce GTX 1070]
driver   : nvidia-driver-396 - third-party free recommended
driver   : nvidia-driver-390 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

Update2

taken from https://forums.developer.nvidia.com/t/390-x-unable-to-modify-gpumemorytransferrateoffset-and-gpugraphicsclockoffset-via-nvidia-settings/59241

nvidia-settings -a [gpu:0]/GPUMemoryTransferRateOffsetAllPerformanceLevels=${NVIDIA_MEM_OFFSET} -a [gpu:0]/GPUGraphicsClockOffsetAllPerformanceLevels=${NVIDIA_CLOCK_OFFSET}

Ubuntu 20.04 disable sleep mode

based on https://www.unixtutorial.org/disable-sleep-on-ubuntu-server/

systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Disable Automatic upgrades

dpkg-reconfigure unattended-upgrades

Installing nvidia drivers 470

Somehow intially i was not able to install nvidia-driver-470 metapackage directly via apt install or ubuntu-drivers install

ubuntu-drivers list
nvidia-driver-470, (kernel modules provided by linux-modules-nvidia-470-generic-hwe-20.04)
nvidia-driver-460-server, (kernel modules provided by linux-modules-nvidia-460-server-generic-hwe-20.04)
nvidia-driver-460, (kernel modules provided by linux-modules-nvidia-460-generic-hwe-20.04)
nvidia-driver-450-server, (kernel modules provided by linux-modules-nvidia-450-server-generic-hwe-20.04)
apt install linux-modules-nvidia-470-generic-hwe-20.04 (don't forget to add extra-modules and so on depending on your hardware or you might end up with out NIC driver reboot)
after that 
apt install nvidia-driver-470 worked just fine

I used Ubuntu Budgie 17.10 as a host OS. You can use any flavor of ubuntu you preffer that will not change the instructions below.

Before plugging the card let's install nVidia Drivers the easiest way to do so is to use ppa repository, more details here.

I will just summarize below:

sudo -s
add-apt-repository ppa:graphics-drivers
apt update
apt install -y nvidia-390 tmux
exit

Power off the rig and install a card, in my case the xorg.conf was automatically populated with all sections regarding nvidia, all I had to do as to add Coolbits option:

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "None"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
    Option "Coolbits" "28"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

Coolbits allow you to overclock/underclock and reduce power consumption.

In case your xorg.conf is not configured automatically you may use nvidia-xconfig. If you are planing to use a headless rig make sure you have Option "AllowEmptyInitialConfiguration" "on" specified in the configuration.

nvidia-xconfig --enable-all-gpu --cool-bits=28 --allow-empty-initial-configuration
# if --enable-all-gpi gives an error use the command below
nvidia-xconfig -a --cool-bits=28 --allow-empty-initial-configuration

I used ethminer latest binary, grab it from releases section.

The reason I didn't choose a latest stable build as it has this nasty bug with a DNS Lookup failure which is fixed in the latest versions.

sudo -s
mkdir -p /opt/miner
cd /opt/miner
wget https://github.com/ethereum-mining/ethminer/releases/download/v0.14.0.dev3/ethminer-0.14.0.dev3-Linux.tar.gz
tar vfx ethminer*

Let's create a miner service, that will automatically starts the miner on the system boot and restarts it in case it fails. I'm not going to use a watchdog here as I haven't faced any stability issues or system hangs.

Create a file /lib/systemd/system/miner.service that contains:

[Unit]
Description=Miner Tmux Service
#After=console-getty.service
After=getty@tty8.service
Requires=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/tmux new-session /opt/miner/start.sh
Restart=always
RestartSec=3s
StandardInput=tty
TTYPath=/dev/tty8
TTYReset=yes
TTYVHangup=yes

[Install]
WantedBy=multi-user.target

Use systemctl enable miner.service to register it with a systemd.

start.sh should be executable chmod +x ./start.sh

Example:

#!/bin/bash

export GPU_FORCE_64BIT_PTR=0
export GPU_MAX_HEAP_SIZE=100
export GPU_USE_SYNC_OBJECTS=1
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100

/opt/miner/bin/ethminer -RH -HWMON --api-port 8080 --farm-recheck 200 -U -S eu1.ethermine.org:4444 -FS us1.ethermine.org:4444 -O <your_wallet_public_key>.cerberus

The new format is:

/opt/miner/bin/ethminer -RH -HWMON --api-port 8080 --farm-recheck 200 -U -P stratum+tcp://0x1.cerberus@eu1.ethermine.org:4444 -P stratum+tcp://0x1.cerberus@us1.ethermine.org:4444

ethminer has a JSON API that is compatible with the one from Clamore's, you can try something like: echo '{"id":17,"jsonrpc":"2.0","method":"miner_getstat1"}' | timeout 1 nc localhost 8080 to read your stats for e.g. zabbix. You can get a description of fields here.

You can also install an http proxy to control your rig or read stats via http, take a look at this project ethminer-http-api on github.

Underclocking and reducing power consumption

By default the card consumes around 160 Watts and produces around 26MH/s which is not a lot.

I have got a stable above 32MH/s from this card with a 120W power limit and a little under 32MH/s with 110W. You need X11 running to be able to underclock nvidia cards. Run 'nvidia-smi' to see what applications are currently using it. Chances are it is Xorg and your windows manager.

ps -ef | grep Xorg
root       807   754  0 13:20 tty7     00:00:01 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

Note the auth we will need it if using headless setup.

DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 /usr/bin/nvidia-smi -i 0 -pl 120
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 /usr/bin/nvidia-settings --assign "[gpu:0]/GPUGraphicsClockOffset[3]=-200" --assign "[gpu:0]/GPUMemoryTransferRateOffset[3]=1400"

The above comands are for a single card setup, that has index 0. The first line reduces power consumption from 180W to 120W, second underclocks GPU core and overclocks memory that is a crucial part for ethash algorythm. Underlocking the core allows to reduce the power consumption to my understanding.

I have used /etc/rc.local to make this settings applied on startup, as I didn't want them to be permanent. On ubuntu 17.10 rc.local is not present by default.

Create rc.local and make it executable, so systemd will execute via the service:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 /usr/bin/nvidia-smi -i 0 -pl 120
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 /usr/bin/nvidia-settings --assign "[gpu:0]/GPUGraphicsClockOffset[3]=-200" --assign "[gpu:0]/GPUMemoryTransferRateOffset[3]=1400"

exit 0

That's basically it. I didn't find a need to control GPU fans manually, but again you can do that using nvidia-settings:

 sudo nvidia-settings -c :0 -a [gpu:0]/GPUFanControlState=1
 sudo nvidia-settings -c :0 -a [fan:0]/GPUTargetFanSpeed=60 

Cheers!

A sample output from a single card rig:

{
   "result" : [
      "0.14.0.dev3",
      "109",
      "32286;54;0", <- KH/s for GPU0
      "32286", <- KH/s total
      "0;0;0",
      "off",
      "56;33", <- Temperature and Fan 
      "eu1.ethermine.org:4444",
      "0;0;0;0"
   ],
   "jsonrpc" : "2.0",
   "id" : 17
}
@stralex7
Copy link
Author

Options -S and -O is deprecated and replaced by -P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment