Docker Installation for NVidia and Linux

This document guides you from a freshly set up rig to a rig running MiningOptimizer in a docker container.

Please note: you need to have root permissions since you will be installing drivers and software.

If you already have bin running docker containers with access to nvidia drivers on your machine, you can skip step1 and step2.

Disclaimer: this is how we set up the docker on our rigs. It may work differently on yours. If you find any errors in this guide please let us now, so we can correct it. This guide is for NVIDIA only.

Step1: Install NVidia Drivers

If you have already installed NVidia Drivers on your rig, you can skip this step. You can find out by running nvidia-smi command. If it provides reasonable output, you can skip this section. Otherwise please continue.

If your rig is completely new, you can skip the next section, it removes old installations.

sudo apt-get update
sudo apt-get purge cuda
sudo apt-get purge libcudnn6
sudo apt-get purge libcudnn6-dev

Then go on with:

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb

sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb

and finally the installation:

sudo apt-get update
sudo apt-get install cuda=9.1.85-1

Now reboot the machine. After the reboot you should be able to execute nvidia-smi without errors. The output should be something like this:

Ok, so step1 is finished, you have running nvidia drivers on your rig. Now step2 is to get the docker running. Again, if you already have a docker running on your machine, you can skip the following step.

Step2: Install docker and nvidia-runtime.

First you have to actually install a docker:

sudo apt-get install software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo service docker restart

Now install nvidia-runtime for the docker (ubuntu 16.04)

curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
  sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/nvidia-container-runtime.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update

sudo apt-get install nvidia-container-runtime

Finally configure the docker to use nvidia-runtime:

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

Now you have a docker able to run nvidia runtime. The simplest way to see if it works is to execute the same nvidia-smi command, but now from within the container:

sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

You should see the same output as in step2. Now lets finally install MiningOptimizer!

Step3: Installing the MiningOptimizer container and setting it up

Now we are getting to the fun part, installing the MiningOptimizer. Just follow this step by step instruction.

You will need a folder on the host machine to put configurations and logs, so that they can survive container restart. We call this <miningoptimizer-home>. It can be located anywhere on your host machine, we will refer to it as <miningoptimizer-home> in the document.

a) pull the docker container

docker pull miningoptimizernvidia/nvidia:latest

This will download our container. Please be patient, it can take a while. After the container is downloaded you can start it:

b) download and edit the config file

There is a config file in the container which contains an API key (and two additional options). This API Key is used to assign the rig to your account so you absolutely want to set it properly. Currently you will have to repeat this procedure for every rig, but we are already working on a solution to this problem.

  • Login to your account on www.miningoptimizer.net (or create one).
  • Navigate to Settings | API Key and download the config

Finally put the downloaded config.properties file into a folder <miningoptimizer-home>/conf.

c) start container

docker run --runtime=nvidia -v <miningoptimizer-home>/conf:/miningoptimizer/conf -v <miningoptimizer-home>/log:/miningoptimizer/log -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -e RIG_NAME=<RIGNAME> -tid miningoptimizer/nvidia:latest

Pay attention to the RIG_NAME, you should always select a different one for each rig, since this is how the system will recognize this particular rig.

The miningoptimizer-home directory is the directory where you place your logs and configs and everything else. You can choose a different directory as well.

d) finally start the mining process

Now change into subfolder jre and start the client:

cd jre
./start_client.sh

After a couple of minutes the client will start a screen session for the main controlling process, and a separate screen session for every GPU. You can join into the screen sessions if you want to check on the status, but please, never hit ctrl-c while in one. Here is a short overview:

  • screen -list – provides a list of all screens.
  • screen -r “screenname” – re-attaches to the screen, for example: screen -r “25.miningclient”
  • ctrl a d – to exit from the screen without killing the process in it.

So this is basically it! After a short period of time you will see your new rig in the interface:

Enjoy and please don’t hesitate to get in touch with us.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>