As explained in our
How to mine Monero on Windows or Linux
(Fedora or Ubuntu) with CPU guide, Monero is one of the few cryptocurrencies which can still be mined using a CPU;
nevertheless, GPUs can provide significant performance improvements and often, more value. In this guide we
will first elaborate on some Monero GPU mining topics and then continue with a step-by-step guide on mining Monero
using GPU in the
Fedora and
Ubuntu Linux distributions.
Advantages and Disadvantages of GPU mining
a. Support for multiple GPUs
A computer or server may support two CPUs, but with the right hardware, it can support up to 19 GPUs.
According to
monerobenchmarks.info the highest performing CPU
is an Intel Xeon E7-8867 v4 (around 4000 hashes per second), which has a recommended price of $4672 USD.
Add the cost of a supported motherboard and additional required hardware and the entire mining rig will
be near $6000 USD. Such a rig cannot be expanded in the future with additional CPUs.
Buying an inexpensive motherboards, and multiple GPUs can provide more hashing power for the price.
Check out
monerobenchmarks.info to compare GPU performance when
considering GPU mining. For example, using six Nvidia GTX 1060 GPUs can generate nearly 3000 hps, and it can
cost around $300 for each card. A mining rig can be completed with a single GPU and as the budget increases,
additional GPUs can be added.
b. Expandable and Flexible
Most motherboards have a limited form factor and will only support specific types of CPUs. New, higher
performing CPUs will likely require a completely new build for an upgrade.
GPUs interface using the PCI-e specification and nearly all modern motherboards support this specification.
GPUs can be added, removed, and replaced with different models as desired.
c. Specific use case
While a CPU is a general purpose machine and could be re-purposed for nearly anything (e.g. home server),
a multi-GPU rig built for mining is less useful if not used for this purpose. One or two cards could be
used for a gaming machine, but a 19 card rig may only be useful for niche cases such as machine-learning.
d. Purchase options
GPU mining is popular, historically profitable, and the demand for GPUs is high. Online as well as brick and
mortar stores often place limits on the number of GPUs available for purchase and the prices reflect
accordingly. Finding enough GPUs for a build can be challenging.
GPU mining on Linux vs Windows and Mac
Windows has excellent support for both Nvidia and AMD GPUs. Drivers are readily available, configuration
software works well, and overclocking is fairly simple. Mining using Windows with GPUs is an excellent
choice with purchased Windows licensing, experience in the Windows environment, and availability of a
GUI based setup.
Mac also has robust support for both Nvidia and AMD GPUs. The hardware is often more expensive, but if
already available, can be re-purposed easily for mining Monero.
On the other hand, Linux has historically struggled to support GPUs but currently works well with nearly
every modern GPU architecture. Drivers for both Nvidia and AMD are widely available, multiple mining
software options support Linux, and most Linux distros work well. Linux requires no licensing, can be
changed easily, and works very well in headless environments (can connect over a network).
Solo vs Pool mining
Solo mining requires connection to a full Monero node and a fairly large mining environment to be feasible.
Miners will likely go long periods of time with no rewards but will not be required to pay any fees once
a block is found. For example, using the six GTX 1060 GPUs mentioned before, a solo miner has about a
1% chance of finding a block every 24 hours. Mathematically, this means a miner will get a reward every
100 days. As mining difficulty changes, this may become more or less likely.
A pool is a collection of miners who combine their hashing power and then share the rewards. Individual
miners are not required to maintain a full Monero node, but just connect to a mining pool using mining
software. Miners are rewarded more frequently, but in smaller amounts. For example, rather than receiving
1 XMR on day 100 solo mining, a miner receives .01 xmr every day for 100 days.
Additionally, pools often have fees associated with them to cover the overhead of running the pool.
Pools also may have minimum payouts to reduce the overhead and network fees of frequent, low payments. Most
mining software are configured to use a pool by default.
If you would like to know how much can you earn by mining Monero then use our
Monero mining calculator.
Minergate
The Monero community is very skeptical of Minergate due to many reports of lowered hash rates. There are
numerous options for highly regarded, high quality Monero pools and the use of Minergate is not recommended.
To mine with Nvidia, both Nvidia drivers and Cuda toolkit are required.
Downloading and Installing the Nvidia Drivers
Download the Nvidia drivers from
here.
Install the requisite packages for driver compilation and making the project.
The installation assumees the driver is located within the
/tmp directory.
dnf install kernel-devel kernel-headers gcc gcc-c++ dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig vim git cmake automake openssl-devel libcurl-devel -y
Nvidia won't install unless the conflicting Nouveau module is disabled. By adding this line to the
blacklist.conf file, the kernel won't load the Nouveau module.
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
Edit the grub menu to blacklist nouveau by appending to the
GRUB_CMDLINE_LINUX variable value.
vim /etc/sysconfig/grub
GRUB\_CMDLINE\_LINUX="......quiet rd.driver.blacklist=nouveau"
Update the grub2 configuration.
For
BIOS:
grub2-mkconfig -o /boot/grub2/grub.cfg
Or for
UEFI:
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
Remove
xorg-x11-drv-nouveau. Note that this may or may not be
required depending on the installation environment.
dnf remove xorg-x11-drv-nouveau
Additionally, remove any exclusion reference in
dnf.conf if it exists.
vim /etc/dnf/dnf.conf
exclude=xorg-x11*
Back-up the old
initramfs nouveau image and create a new one.
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
ls /boot
dracut /boot/initramfs-$(uname -r).img $(uname -r)
Reboot to runlevel 3. Note that the GUI (desktop environment) may be unavailable. Save this guide
for reference outside of the Fedora machine updating.
systemctl set-default multi-user.target
reboot
After the reboot is completes, run the driver installation.
cd /tmp
chmod +x NVIDIA-Linux*
./NVIDIA-Linux* --silent
Downloading and Installing the Cuda Toolkit
Download the Cuda toolkit from
here.
Install the Cuda toolkit and reboot the system. The installation assumees the installation file is located within the
/tmp directory.
cd /tmp
sudo rpm -i cuda-repo*
sudo dnf clean all
sudo dnf install cuda -y
PATH=$PATH:/usr/local/cuda/bin
sudo reboot
Mining Monero using xmr-stak
xmr-stak supports both CPU and/or GPU mining. It can be
configured to run CPU, Nvidia GPU, or AMD GPU modes, or any combination of the three.
Install dependencies, get the source, and make the project. The default values will enable both CPU
and GPU mining. To disable CPU mining, add the
-DCPU_ENABLE=FALSE
flag to the
cmake line. If you are not using AMD GPUs also add
the flag to disable AMD,
-DOpenCL_ENABLE=FALSE.
sudo dnf install gcc gcc-c++ hwloc-devel libmicrohttpd-devel libstdc++-static make openssl-devel cmake
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install
Configure the software by running
xmr-stak for the first time.
Dual mining configurations are supported.
cd bin
./xmr-stak
xmr-stak will prompt for values as shown below. It will also
automatically generate default values which work well.
Please enter:
- Currency: 'monero' or 'aeon'
monero
- Pool address: e.g. pool.usxmrpool.com:3333
MONERO_POOL_ADDRESS_HERE
- Username (wallet address or pool login):
WALLET_ADDRESS_HERE
- Password (mostly empty or x):
x
- Does this pool port support TLS/SSL? Use no if unknown. (y/N)
N
- Do you want to use nicehash on this pool? (y/n)
n
- Do you want to use multiple pools? (y/n)
n
xmr-stak.com has community submitted configurations for
increased performance. To optimize for a particular CPU/GPU, view the configurations there.
Optimization will require some trial and error.
To use both CPU and GPU mining, enable the dependency for
hwloc
and
hugepages.
sudo sysctl -w vm.nr_hugepages=128
sudo echo "* soft memlock 262144" >> /etc/security/limits.conf
sudo echo "* hard memlocl 262144" >> /etc/security/limits.conf
To run the mining software, execute
xmr-stak a second time.
./xmr-stak
Mining Monero using ccminer-cryptonight
ccminer-cryptonight is another option for mining using an
Nvidia GPU. It is more specific than
xmr-stak.com as it only
supports Nvidia GPUs. It does not support CPU mining nor AMD GPUs.
cd /tmp
git clone https://github.com/KlausT/ccminer-cryptonight.git
ccminer-cryptonight expects some specific libraries included
in OpenSSL v1.0. Therefore, the
Autoconf file needs to be
adapted to check for the 1.0 or 1.1 library.
vim /tmp/ccminer-cryptonight/configure.ac
AC_CHECK_LIB([ssl],[SSL_library_init], [], [AC_MSG_ERROR([OpenSSL library required])])
ACCEPT_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [ACCEPT_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [ACCEPT_SSL_LIB="yes"])
AS_IF([test "x$ACCEPT_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
Make and install the software.
cd /tmp/ccminer-cryptonight
./autogen.sh
./configure
Cuda requires gcc version 5 or lower. Modify the MakeFile to use backwards compatibility by appending
-Xcompiler -std=c++98.
cd /tmp/ccminer-cryptonight
vim MakeFile.am
$(NVCC) @CFLAGS@ -I . $(NVCC_GENCODE) --maxrregcount=128 --ptxas-options=-v $(JANSSON_INCLUDES) -o $@ -c $<
$(NVCC) -Xcompiler -std=c++98 @CFLAGS@ -I . $(NVCC_GENCODE) --maxrregcount=128 --ptxas-options=-v $(JANSSON_INCLUDES) -o $@ -c $<
ccminer-cryptonight executes a check to determine if the version
of gcc is old enough.
cd /tmp/ccminer-cryptonight
vim miner.h
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#if __GNUC __ > 9
Now, make.
cd /tmp/ccminer-cryptonight
make
ccminer-cryptonight is also configured by default to use a pool.
Start mining by executing the file.
./ccminer -o MONERO_POOL_ADDRESS_HERE -u WALLET_ADDRESS_HERE -p x
To mine with Nvidia, both Nvidia drivers and Cuda toolkit are required.
Downloading and Installing the Nvidia Drivers on Ubuntu
Ubuntu supports the installation of Nvidia drivers from the package manager. Determine the required driver for
the Nvidia GPU used by searching the
Nvidia driver web page.
Take note of the
version as it will be used for the package
installation candidate. For example, the driver for a GeForce GTX 1060 is 390.25 so the package to be installed
would be
nvidia-390.
sudo apt-get install nvidia-390
Alternatively, download the correct driver from the
Nvidia driver web page
and install it by the following commands which assume the driver is located in the
/tmp directory.
cd /tmp
chmod +x NVIDIA-Linux*
./NVIDIA-Linux* --silent
Downloading and Installing the Cuda Toolkit on Ubuntu
Download the Cuda toolkit from
here.
And install the Cuda toolkit. The installation assumees the installation file is located within the
/tmp directory.
cd /tmp
sudo sh cuda_*.run
Mining Monero using xmr-stak on Ubuntu
xmr-stak supports both CPU and/or GPU mining. It can be
configured to run CPU, Nvidia GPU, or AMD GPU modes, or any combination of the three.
Install dependencies, get the source, and make the project. The default values will enable both CPU
and GPU mining. To disable CPU mining, add the
-DCPU_ENABLE=FALSE
flag to the
cmake line. If you are not using AMD GPUs also add
the flag to disable AMD,
-DOpenCL_ENABLE=FALSE.
sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install
Configure the software by running
xmr-stak for the first time.
Dual mining configurations are supported.
cd bin
./xmr-stak
xmr-stak will prompt for values as shown below. It will also
automatically generate default values which work well.
Please enter:
- Currency: 'monero' or 'aeon'
monero
- Pool address: e.g. pool.usxmrpool.com:3333
MONERO_POOL_ADDRESS_HERE
- Username (wallet address or pool login):
WALLET_ADDRESS_HERE
- Password (mostly empty or x):
x
- Does this pool port support TLS/SSL? Use no if unknown. (y/N)
N
- Do you want to use nicehash on this pool? (y/n)
n
- Do you want to use multiple pools? (y/n)
n
xmr-stak.com has community submitted configurations for
increased performance. To optimize for a particular CPU/GPU, view the configurations there.
Optimization will require some trial and error.
To use both CPU and GPU mining, enable the dependency for
hwloc
and
hugepages.
sudo sysctl -w vm.nr_hugepages=128
sudo echo "* soft memlock 262144" >> /etc/security/limits.conf
sudo echo "* hard memlocl 262144" >> /etc/security/limits.conf
To run the mining software, execute
xmr-stak a second time.
./xmr-stak
Mining Monero using ccminer-cryptonight on Ubuntu
ccminer-cryptonight is another option for mining using an
Nvidia GPU. It is more specific than
xmr-stak as it only
supports Nvidia GPUs. It does not support CPU mining nor AMD GPUs.
cd /tmp
git clone https://github.com/KlausT/ccminer-cryptonight.git
ccminer-cryptonight expects some specific libraries included
in OpenSSL v1.0. Therefore, the
Autoconf file needs to be
adapted to check for the 1.0 or 1.1 library.
vim /tmp/ccminer-cryptonight/configure.ac
AC_CHECK_LIB([ssl],[SSL_library_init], [], [AC_MSG_ERROR([OpenSSL library required])])
ACCEPT_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [ACCEPT_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [ACCEPT_SSL_LIB="yes"])
AS_IF([test "x$ACCEPT_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
Make and install the software.
cd /tmp/ccminer-cryptonight
./autogen.sh
./configure
Cuda requires gcc version 5 or lower. Modify the MakeFile to use backwards compatibility by appending
-Xcompiler -std=c++98.
cd /tmp/ccminer-cryptonight
vim MakeFile.am
$(NVCC) @CFLAGS@ -I . $(NVCC_GENCODE) --maxrregcount=128 --ptxas-options=-v $(JANSSON_INCLUDES) -o $@ -c $<
$(NVCC) -Xcompiler -std=c++98 @CFLAGS@ -I . $(NVCC_GENCODE) --maxrregcount=128 --ptxas-options=-v $(JANSSON_INCLUDES) -o $@ -c $<
ccminer-cryptonight executes a check to determine if the version
of gcc is old enough.
cd /tmp/ccminer-cryptonight
vim miner.h
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#if __GNUC __ > 9
Now, make.
cd /tmp/ccminer-cryptonight
make
ccminer-cryptonight is also configured by default to use a pool.
Start mining by executing the file.
./ccminer -o MONERO_POOL_ADDRESS_HERE -u WALLET_ADDRESS_HERE -p x
Mining with AMD GPUs on Ubuntu
AMD released GPU drivers suitable for mining and they are available for Ubuntu. Download the
AMDGPU-PRO driver from the
AMD Driver website.
Install the
AMDGPU-PRO driver. Assuming the installation file is
located within the
/tmp directory.
cd /tmp
tar -Jxvf amdgpu-pro-*.xz
cd amdgpu-pro
sudo ./amdgpu-pro-install*
xmr-stak supports mining with AMD GPUs. Ensure the
-DOpenCL_ENABLE=TRUE flag is set. If no Nvidia GPUs are present,
also set the
-DCUDA_ENABLE=FALSE flag.