I wrote this tutorial because I've seen bits and chips of this topic, but never a full tutorial (especially not an up-to-date one).
This tutorial is intented for miners who want to mine Monero (or any other coin supported by xmr-stak) on a Ubuntu based system, with Nvidia cards (note: the tutorial works fine with CPU-only mining, just skip the driver installing part, and use -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF
flags for cmake)
I assume You have a fresh install of Ubuntu, make sure Your system is up-to-date
sudo apt update && sudo apt upgrade
Install the latest version of the Nvidia driver avialable in the apt repository (which is 384 as of now)
sudo apt install nvidia-384
Note: some newer cards (like the RTX series) may require a newer version of the driver, in which case You should download it directly from Nvidia's page. To install the latest avialable (which is 410 as of now), fetch it from their download server
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/410.93/NVIDIA-Linux-x86_64-410.93.run
Make it executable, and execute it as root
chmod +x NVIDIA-Linux-x86_64-410.93.run
sudo ./NVIDIA-Linux-x86_64-410.93.run
Follow the steps of the installer to have the latest driver installed on Your system
Either way You chose, make sure the driver is really installed
nvidia-smi
It should write some basic information regarding Your GPU(s)
Next thing is setting up CUDA, which is also avialable in our repository
sudo apt install nvidia-cuda-toolkit
As with the Nvidia drivers, they are new (9.1 as of now), but not the newest avialable. As far as I can tell, it supports all Nvidia cards and is suitable for xmr-stak, but if for some reason You need the latest version available (10 as of now), You can download it directly from Nvidia's page
wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
..and execute it
sudo sh cuda_10.0.130_410.48_linux.run
Either way, You should have CUDA installed
nvcc --version
Note: if either nvidia-smi
or nvcc
fails to show the GPU(s), don't panic, just reboot, and they should work perfectly
Now time for the xmr-stak miner itself
First we'll need some libraries and git
sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev git
** Before building xmr-stak, a problem that is encountered on Ubuntu 17.10 and upward, is with the gcc version it comes shipped with (version 7). To compile xmr-stak with CUDA support, we have to use a prior version of gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10
Now You need to clone the repository and build it
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake .. -DOpenCL_ENABLE=OFF
make install
Your binary is ready, to run it
cd ~/xmr-stak/build/bin
chmod +x xmr-stak
./xmr-stak
Now it will guide You through an initial setup
-
Probably choose
0
, unless You'd like to check Your hashrate remotely -
Enter
monero
(or any other coin sopported by xmr-stak) -
Choose a pool, preferably one close to You, and type it in the following format:
pool.example.com:3333
-
Username is pretty much Your wallet address (some pools interpret a rig identifier after Your address, separated with a
.
) -
Password is mostly empty or
x
-
Rig identifier (except for pools mentioned in step 4), could by empty
-
TLS/SSL, in most cases
N
-
Nicehash support, in most cases
n
-
Multiple pools,
n
unless You need multiple pools set up for some reason
That's it, xmr-stak will start mining, you can check Your hashrate anytime by pressing h
I would recommend running xmr-stak on a screen
session, so You can detach it and work on other stuff. In case You haven't used screen before
sudo apt install screen
screen -S miner
cd ~/xmr-stak/build/bin
xmr-stak
Now You can detach with CTRL+A+D
Either way, Your xmr-stak has created some files in the ~/xmr-stak/build/bin
directory (namely config.txt
, cpu.txt
, nvidia.txt
and pools.txt
), You can modify any of them in case You want to reconfigure xmr-stak (most often pools.txt
), or delete them, and You'll be hit with the initial setup again.
I hope this tutorial helped You setting up xmr-stak, all kudos goes to the creators: fireice-uk and psychocrypt
In case You liked this tutorial, consider buying me a beer
46bBSxUwap2Z2BrxqVUoYy21K5TBt7Jva8dpzpiDzawbQqSZd5pmatYK9SXrviDobMAhSSAPRr63K34GNwYNddsMPbSakdK
To fix the gcc --version error add these two lines
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10