Mining Ethereum with AMD 6600 XT on Ubuntu Linux

Warning: Ethereum(ETH) will migrate to PoS(Proof of Stake) algorithm in near future, maybe in a year. So jumping into ETH mining now might or might not be profitable. Also, I do NOT condone crypto mining with fossil fuel based energy source!

Prerequisite: A PC running on Ubuntu 20.04 with stable Internet connection

AMD RX 6600 XT is latest addition to the Big Navi product family. Below are the steps I managed to do ETH mining with a 6600 XT on Ubuntu 20.04.

Installing AMD Radeon Pro driver

The driver for 6600 XT can be downloaded here, and the official instructions for installing the pro driver is here. And the exact commands I used to install are below

# after the driver is downloaded, extract it with tar
$ tar -xvf amdgpu-pro-21.30-1290604-ubuntu-20.04.tar.xz
...
# install the pro version with OpenCL support
$ cd amdgpu-pro-21.30-1290604-ubuntu-20.04/
$ ./amdgpu-pro-install -y --opencl=rocr,legacy
# add current user to video and render group
$ sudo usermod -a -G video $LOGNAME
$ sudo usermod -a -G render $LOGNAME
# reboot to load the driver
$ sudo reboot
...
# install clinfo to check if OpenCL is enabled properly
$ sudo apt install clinfo
$ clinfo
...
Number of devices                                 1
  Device Name                                     gfx1032
...
# success!

Build rocm_smi_lib to set power limit, memory clock speed, etc

With nVidia’s Linux driver, there’s a bundled tool nvidia-smi to control the card’s power limit, etc. But that’s missing from AMD’s driver bundle. Thanks to Radeon Open Compute the rocm_smi_lib is here. It’s source code so I need to build it myself, but it’s quite straight forward.

# install dependencies 
$ sudo apt install cmake g++
# clone the github repo
$ git clone https://github.com/RadeonOpenCompute/rocm_smi_lib.git
# start the build
$ cd rocm_smi_lib/
$ mkdir build
$ cd build
$ cmake ..
...
$ make
...
$ sudo make install
...
# set max power to 55W for the first card
$ /opt/rocm/bin/rocm-smi -d 0 --setpoweroverdrive 55
# check result
$ /opt/rocm/bin/rocm-smi
======================= ROCm System Management Interface =======================
================================= Concise Info =================================
GPU  Temp   AvgPwr  SCLK    MCLK     Fan     Perf  PwrCap  VRAM%  GPU%  
0    55.0c  54.0W   920Mhz  1000Mhz  22.75%  auto  55.0W    61%   99%   
================================================================================
============================= End of ROCm SMI Log ==============================

Install and Start TeamRed Miner

This is the most easy part but has to be done the last 🙂 The latest release can be downloaded here and commands to get the mining started are below

# in Downloads directory
$ tar xvf teamredminer-v0.8.4-linux.tgz
...
$ mv teamredminer-v0.8.4-linux ~/
$ cd ~/teamredminer-v0.8.4-linux/
# in start_eth.sh, replace the ETH wallet address to yours otherwise you will be mining for someone else :)
$ vim start_eth.sh
...
# start mining!
$ ./start_eth.sh
[2021-08-22 10:06:25] Pool asia1.ethermine.org received new job. (job_id: 0x65d72f5b396..., diff 1.000 / 4295 MH)
...

If this actually helped you, you’re welcome to support my blogging by running your mining rig with my wallet( 0x0016a5e2d5a32d40f89475218427d35798d05d8a ) for a few hours. Or maybe just click on an ad. which is much easier.

🙂

EDIT: It seemed when 2 6600 XT cards are plugged in only 1 of them becomes available to OpenCL.

Ethereum(Crypto) Mining with Nvidia 3070(Ampere) on Ubuntu 20.04 with Renewable Energy

Snagged a pair of RTX 3070 cards. With only 2 cards this is more like an experiment than an investment.

I’ve done Crypto mining before and since the price is now almost all time high I’ll do that again, but only with my solar energy. Mining with dirty coal power isn’t ethical any more as the climate change has accelerated in the past few years.

To start ETH mining here are some prerequisites:

  • Energy efficient video cards, in this case I got RTX 3070. 3060TI is also a good choice but it was sold out already
  • A desktop computer where you can attach multiple video cards to PCI express slots. But I’m not focusing hardware installation here, ie. not showing how to install the card and connect cables, etc.
  • My OS is Ubuntu 20.04 so I choose t-rex miner which has better support for Nvidia Ampere architecture. The releases can be found here

Here are the steps with which I set up t-rex miner on my Ubuntu 20.04 desktop:

# as root user
sudo -i
# install nvidia 460 driver for Ubuntu
apt install nvidia-driver-460
# install t-rex to /opt/t-rex
mkdir /opt/t-rex
wget https://github.com/trexminer/T-Rex/releases/download/0.19.9/t-rex-0.19.9-linux-cuda11.1.tar.gz
tar -zxvf t-rex-0.19.9-linux-cuda11.1.tar.gz -C /opt/t-rex
# change ownership for security reasons
chown -R nobody:nogroup /opt/t-rex

Now in directory /opt/t-rex there are many shell script(.sh) files. I was using ethermine.org so I had a look at ETH-ethermine.sh, it has:

#!/bin/sh
./t-rex -a ethash -o stratum+tcp://eu1.ethermine.org:4444 -u <ETH wallet address> -p x -w <worker name>

Since I’m proudly an experienced Linux user, I choose to create a systemd service out of that shell script:

# cat /etc/systemd/system/ethminer.service 
[Unit]
Description=Ethereum Miner

[Service]
Type=simple
User=nobody
ExecStart=/opt/t-rex/t-rex -a ethash -o stratum+tcp://us2.ethermine.org:4444 -u <my ETH wallet address> -p "" -w <my worker name, can be hostname>

Restart=on-failure

[Install]
WantedBy=multi-user.target

I choose us2 node as it’s geologically close to me. The user is set to nobody so it won’t cause harm to my system if it wants to. Then the service can be enabled and started with systemctl command:

# reload systemd as a new service is added
# following commands run as root user
systemctl daemon-reload
# enable the service so it starts automatically
systemctl enable ethminer
# start the service
systemctl start ethminer
# check status
systemctl status -l ethminer
# watch the logs
journalctl -f |grep t-rex
Jan 24 13:55:30 hostname t-rex[6621]: 20210124 13:55:30 Mining at us2.ethermine.org:4444, diff: 4.00 G
...

According to other miners online, the TDP of 3070 is better set as 50%(130W), because it can run hotter with higher wattage but won’t make it compute faster. Here’s how I use a cronjob to set TDP to 130W except when I’m playing a game(assuming I’ll stop the miner when playing some game on it).

EDIT: 115W is good enough.

# still as root user, as only root can use <code>nvidia-</code>smi command
# crontab -l
*/10 * * * * /bin/ps -C t-rex &amp;&amp; /usr/bin/nvidia-smi -i 0 -pl 115 2>&1 >>/var/log/nvidia.log

This can be verified in t-rex ‘s logs

journalctl -f |grep t-rex
Jan 24 13:55:30 hostname t-rex[6621]: 20210124 13:55:30 GPU #0: Gigabyte RTX 3070 - 52.07 MH/s, [T:53C, P:129W, F:60%, E:404kH/W], 1370/1370 R:0%
# it's running at 129W and temperature is 53 degree and fan speed cruising at 60%

Regarding mining solely with solar energy, there can be 3 approaches:

  • Switch electricity supplier to the renewable-friendly ones such as Ember, so you can use solar energy generated by community and enjoy the low wholesale price and mine crypto when the sun shines. This requires the API access supplier so you know when the energy is from renewables and cheap
  • Install and use your own solar energy to mine crypto when the sun shines. This requires API access from your inverter so know when to start mining with enough solar energy.
  • Install solar and battery so it’s guaranteed to mine with your own solar energy until the battery runs flat of course

I’m going with the last option 🙂

Install Nvidia 396 Driver for Ubuntu 18.04

Just some quick notes to upgrade Nvidia driver from 390 to 396 on Ubuntu 18.04. By default Ubuntu 18.04 only has Nvidia driver 390.

# add ubuntu official ppa for nvidia
# all commands below run as root
add-apt-repository ppa:graphics-drivers/ppa
apt update
# install 396 files
apt install nvidia-dkms-396 nvidia-driver-396 nvidia-compute-utils-396 libnvidia-compute-396
# reboot at the end.

After reboot, the new driver can be verified by:

nvidia-smi 
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.54 Driver Version: 396.54 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1070 Off | 00000000:01:00.0 Off | N/A |
| 44% 67C P2 150W / 230W | 3211MiB / 8117MiB | 100% Default |
+-------------------------------+----------------------+----------------------+

🙂

Mining ZCash on Ubuntu Linux

I didn’t quite believe that mining crypto currencies is viable as an individual, until I saw the news that AMD graphics cards were sold out because they’re good at mining Ethereum. To be convinced I tried to order AMD RX 570 from some online vendors, and they all cancelled my orders and refunded me shortly.

So even if I wanted to mine Ethereum I will have to wait indefinitely for the AMD cards to be re-stocked. At least I can buy some NVidia GTX 1070 cards and mine ZCash instead, before NVidia cards are sold out.

Here’s how to mine ZCash with NVidia cards on Ubuntu.

First, you need a wallet so I can receive payments, if there will be any.  It’s quite easy to install zcash on Arch Linux(because I run Arch on my laptop):

sudo pacman -S zcash
mkdir .zcash
echo "addnode=mainnet.z.cash" >~/.zcash/zcash.conf
echo "rpcuser=<your user>" >>~/.zcash/zcash.conf
echo "rpcpassword=`head -c 32 /dev/urandom | base64`" >>~/.zcash/zcash.conf

For other operating systems, see https://z.cash/download.html

Then you can download the bootstrap data with

zcash-fetch-params

It will download about 800MB, after finished, you can start your wallet with

zcashd

When it’s running, you can use zcash-cli command to create your wallet:

zcash-cli getnewaddress

There will be a long hash started with ‘t’, which is a transparent address, with which you can send and receive zcash. You don’t have to run your wallet and your miner on the same machine, but your miner will use the t address(you will get paid to your wallet).

Now onto your miner machine. You will need to install some dependencies for the miner:

sudo apt-get install nvidia-opencl-dev nvidia-375

System needs to be restarted to load the driver. You can load the driver without restarting too, eg. sudo modprobe nvidia-375. Then you can follow the post below to use the miner:

https://bitcointalk.org/index.php?topic=1707546.0

🙂