ETH x Nvidia x Ubuntu

Aurélien Didier
Coinmonks
Published in
6 min readApr 18, 2021

--

Actual logs of Ethminer on Ubuntu

We’ll show how to quickly setup an ETH mining rig on Ubuntu using Nvidia GPU(s).

Ubuntu preset

This whole setup has been tested on both Ubuntu 18 and 20 but I would personally recommend sticking with 18 for stability.

Setup driver and CUDA toolkit

In order to use your GPU card to mine, you’ll need to be able to run code on it. Nvidia provides drivers and toolkit (CUDA) for that. Good news, you can setup both at once, in an easy install.

After a few attempts (as of December 2020), I would recommend not to use the very last versions of the toolkit (11.2) but rather go with one of the previous ones (11.1.1).
Here is the direct link https://developer.nvidia.com/cuda-11.1.1-download-archive. Just follow the selectors in order to match your system and you should end up on:

wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
sudo sh cuda_11.1.1_455.32.00_linux.run

The installer needs to first check the system and once validated you should see the licence agreement menu.

Install Nvidia drivers on Ubuntu
Nvidia End User Licence Agreement

You can write “accept” and let it setup itself.
You’ll end up on a menu where you can select what is going to be installed on your computer. Make sure to install the driver and the CUDA toolkit. CUDA samples are cool if you want to test the setup.
Installation should last a few minutes tops. Once installed you should get a summary of what has been installed and what has not, and 2 important pieces of information: the location of the logs and the command to uninstall the Nvidia driver and the toolkit. You won’t have to care about them until you need to debug though!

Also, don’t forget to restart your machine after setting up drivers. A good way to detect if the driver is setup properly: at boot the GPU(s) fans won’t start. Why? Because now the card is managed with its optimal configuration, and most cards can optimize the fans usage when they don’t process anything. If the driver is not properly setup, the fans will automatically start when the card turns on.

Ethminer Setup

Now that you got the CUDA driver and toolkit ready, you need to build the Ethereum miner, the software part of the mining process.

I’m going to give you a fast track, and you’ll find all the details here: https://github.com/ethereum-mining/ethminer/blob/master/docs/BUILD.md and here: https://linuxhint.com/mine-etherium-ethminer-ubuntu/

First, install necessary tools. CMake will be used for build and mesa is a 3D graphics library:

apt-get install git mesa-common-dev cmake

Clone the ethminer repo in a dedicated folder and update the submodules:

git submodule update — init — recursive

Once this is set, configure the install:

mkdir build && cd build
cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
cmake — build .

Flags -DETHASHCUDA=ON -DETHASHCL=OFF are just meant to tell the program to prepare the setup for CUDA and not OpenCL.

Eventually you can install:

sudo make install

Let’s do a quick check:

ethminer -U -M

By running this, you will know:
- if ethminer is correctly setup
- if ethminer sees and can use your NVidia GPU(s)
- the hashrate you can get from your GPU(s)
This beanchmark should give you an idea of the hashrate you should get with your GPU(s): https://whattomine.com/gpus.

If you’ve completed these steps, congratulation you’ve installed ethminer with NVidia GPU!

Run

A plethora of articles and documentation online can explain you what is “mining”. To keep it simple, let’s just say you’re doing lots and lots of calculation and you’re being awarded with the precious mineral.
In order to do that, you have to connect to a mining platform, that will register your work and compensate you in return. This translates into that command:

ethminer -P -U stratum1+tcp://[WALLET].[RIG]@[SERVER]:[PORT]

Where wallet is your wallet address, and server is the server you’ve chosen to mine with. Port will be told by the server configuration and rig is optional until you’ve got several rigs.

For instance, for small rigs, I would recommend Ethermine.org, and this would be how you get the config: https://ethermine.org/start.

A final checklist before becoming officially a miner:
- make sure your PSU is powerful and stable enough for your GPU(s), especially if you have several of them.
- make sure the airflow is not blocked by anything, and your rig i not too close to another source of heat.
- make sure it’s isolated enough. Fans will be running 100% of the time and that can be noisy.

I’d recommend you run the miner within tmux, and then track your rigs on the service for which you mine. In case of issue, hardware or software, you’ll see a decrease and you can also be notified by email if your miner is down.
Most likely causes: unstable PSU, overheat (cause the GPU to shut down until it gets colder), unstable connection…

Underclocking

You’re probably used to -or know about- over-clocking. In both cases we’re looking at optimizing the GPU. In that case, I’ll only introduce you to the savvy side, basically reducing power, in order to optimize electric consumption.
You’ve got several overclocking software in Windows such as MSI Afterburner, CPU-Z, GPU-Z… Which are, unless it has changed recently, not available on linux distributions.

Some mining software on Windows will recommend over-clocking the memory clock while lowering the voltage of the GPU to optimize matrix calculations and not burn clocks. As far as I know, we can’t make exactly the same edits in Linux.

GWE

GreenWithEnvy (Green With Envy-dia?) is the tool you’re looking for. I won’t go through the setup of it, but that will allow us to cut the power usage.
Recent GPU cards are optimized rendering, 3D, shaders… and basically you don’t need all of it while mining. GWE will let you lower the power limit of the card.

Example with a Gainward 3060TI OC:
- Base hashrate (Power limit 200W): 51–54 MH/s
- Over-clocking (clock and voltage): 60 MH/s (according to Nicehash)
- Lowered power limit with GWE (tested at 130W): 50–51 MH/s
In other words, you can simply save 35% of power and still get a nice competitive hashrate on Linux. If you want to experiment more, I’d recommend you setup Windows and MSI Afterburner.
One caveat, GWE is not multi-gpu friendly yet. You can still tweak the first GPU with it.

Test by limiting the power of the first card. From 200W to 130W
cu0 is limited to 130W here, and stays close to the perf of cu1, which is not limited

Hope you enjoyed it and if you got your rig up and running, feel free to contribute to 0xA86bEc61bDbe257cBf13442EF4FAf849e6CEe971 if you feel this helped you.
If you have any questions or troubles, I’ll be happy to assist you for debug!

Join Coinmonks Telegram Channel and learn about crypto trading and investing

Also Read

--

--