Cryptocurrency Mining.txt - Notepad

How to create a Ubuntu 18.04 NVIDIA Cryptocurrency Miner (RavenCoin Focused)

Install Ubuntu 18.04. I went with desktop.

apt-get install xorg-dev

Go to https://developer.nvidia.com/cuda-zone and download the deb (network) file for the CUDA installation:

sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb

sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

sudo apt-get update

sudo apt-get install cuda

Now to install the NVIDIA driver:

apt-add-repository ppa:graphics-drivers/ppa

apt-get install nvidia-driver-415 (or whatever is listed as the latest)

You may now need to reboot your PC.

You can confirm CUDA and NVIDIA driver version using nvidia-smi

You need to configure cool-bits on nvidia config to control the GPU fan speed:

nvidia-xconfig -a --cool-bits=4 --allow-empty-initial-configuration

You can check this config in /etc/X11/xorg.conf. If the command doesn't work, reboot and try again.

NOTE updating the nvidia driver requires you to remove the current driver first ie sudo apt-get purge nvidia*

The z-enemy miner can be downloaded from bitcoin talk. Get the version that is appropriate for your CUDA version. It is a single file.

Install pre-req:

apt-get install libcurl3

Sample invocation:

./z-enemy -a x16r -o stratum+tcp://rvn.suprnova.cc:6667 -u name.name -p 'password' -i 21 &

Now that the miner has been verified as functional, apply some tweaks such as enabling ssh and booting to CLI instead of GUI:

systemctl set-default runlevel3.target

apt-get install openssh-server

Next you will need to undervolt your GPUs and set your GPU fan speed to maintain a reasonable temperature ie 60.

Create /root/.xinitrc file with the below settings:

nvidia-settings -q fans

nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=80

nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:1]/GPUTargetFanSpeed=80

nvidia-settings -a [gpu:2]/GPUFanControlState=1 -a [fan:2]/GPUTargetFanSpeed=80

nvidia-settings -a [gpu:3]/GPUFanControlState=1 -a [fan:3]/GPUTargetFanSpeed=80

nvidia-smi -i 0 -pl 85

nvidia-smi -i 1 -pl 85

nvidia-smi -i 2 -pl 120

nvidia-smi -i 3 -pl 85

cat

Start a xwindows shell in the background of your SSH session to read /root/.xinitrc and apply the above settings:

startx -- :0 &

There are ways to apply core and memory overclocking on Nvidia GPUs using Ubuntu, but I am mining ravencoin and prefer using stock settings for this.

The below is an interesting command which will suggest what nvidia drivers are most suitable for your GPU:

ubuntu-drivers devices

Autoinstall the recommended drivers:

ubuntu-drivers autoinstall


NOTE, my preferred method is the below to get multiple GPUs working.

Run the below to create your nvidia config file with cool bits 28 which enables all of the fancy overclocking and fan and temperature controls.

sudo nvidia-xconfig -a --cool-bits=28 --allow-empty-initial-configuration

This creates a file at /etc/X11/xorg.conf

You can then copy this file to your xorg.conf.d directory.

sudo cp -f /etc/X11/xorg.conf /usr/share/X11/xorg.conf.d/20-nvidia.conf

Note, you can have multiple nvidia.conf files in this directory. but the one with the largest number will be read.

Lesson learnt

So after installing lubuntu and setting coolbits I've found you need to set the below if you want to run a headless GPU miner.

sudo vi /etc/X11/Xwrapper.config

Add:

allowed_users=anybody

X :0 &

export DISPLAY=:0

If you run subsequent ssh sessions you can run the above export command so that you overclock your GPUS. Sample overclock script below:

# Fan speed
nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=70
nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:1]/GPUTargetFanSpeed=65
# Memory clock
nvidia-settings -a [gpu:0]/GPUMemoryTransferRateOffset[3]=1200
nvidia-settings -a [gpu:1]/GPUMemoryTransferRateOffset[4]=2200
# Core clock
nvidia-settings -a [gpu:0]/GPUGraphicsClockOffset[3]=0
nvidia-settings -a [gpu:1]/GPUGraphicsClockOffset[4]=0
# Power settings
sudo nvidia-smi -pm 1
nvidia-smi -i 0 -pl 115
nvidia-smi -i 1 -pl 140

I also found that modern GPUs have separate settings for individual fans.
To view all your GPU fans run:
nvidia-settings -q fans | grep "\[fan"
You can then configure speeds for both fans on the same GPU.
nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:1]/GPUTargetFanSpeed=75
nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:2]/GPUTargetFanSpeed=75