Although mining Ethereum is way easier on Windows (just keep bashing next in a few installers), there is probably a Hashrate improvement when you're using a Linux as your driver. Moreover, it's way more bad ass.

In this example I'm showing the simple steps on how to get started with GPU-Mining, by manually building Ethminer and setting it up to mine using Nanopool (although it'll work for other pools too).

Noob Notice

Mining will shorten the lifetime of your hardware and causes your PC to use more power, thus driving up your power bill. Also, you might lose all the money you invest. Thus, use your brain!

You, and only you, are responsible for any damage done to you, your hardware or financially.

TL;DR

Ensure you install the latest AMDGPU-pro drivers with OpenCL support first.

apt-get install opencl-amdgpu-pro-icd cmake git mesa-common-dev
git clone https://github.com/ethereum-mining/ethminer.git
cd ethminer
git submodule update --init --recursive
mkdir build; cd build
cmake .. -DETHASHCUDA=OFF -DETHASHCL=ON
cmake --build . -- -j
sudo make install
ethminer -G -M 0
ethminer -G --report-hr -P stratum1+tcp://0x47e83baffbc118393c082b7d4a62130b0480bb11.rigname@eth-eu1.nanopool.org:9999
apt-get install nvidia-cuda-toolkit cmake mesa-common-dev
git clone https://github.com/ethereum-mining/ethminer.git
cd ethminer
git submodule update --init --recursive
mkdir build; cd build
cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
cmake --build . -- -j
sudo make install
ethminer -U -M 0
ethminer -U --report-hr -P stratum1+tcp://0x47e83baffbc118393c082b7d4a62130b0480bb11.rigname@eth-eu1.nanopool.org:9999

Ethereum versus Bitcoin

Bitcoin uses the Hashcash algorithm to verify transactions, which is a relatively simple calculation, which has been put on ASIC's that are capable of outperform many GPU's. Ethereum however, uses the Ethash algorithm, which is set up in such a way that it requires a big amount of Memory. This makes it very hard to transfer the algorithm onto ASIC's but makes GPU's the best method of mining it.

As a result, the difficulty of mining Ethereum increases much slower compared to other currencies using the Hashcash algorithm. Furthermore, it's optimized for mining with GPU's only and it even works when you're using an NVidia card, although AMD probably gives you a bigger bang for the buck.

Requirements

Since Ethereum is optimized for GPU mining, one or more powerfull GPU's are great. Again, it doesn't matter if it's NVidia or AMD, though I prefer using the latter.

Also, make sure your GPU has enough memory. You might want to use a DAG size calculator to find out what you need. At the time of writing a 4GB card might barely work (if you stop gdm3 or lightdm).

Also, you need a Wallet to provide your unique Ether-address. Personally I recommend using Exodus, since it's easy to set up, supports multiple currencies, and doesn't eat all your system's resources like Mist does. Since I don't like the idea of others keeping your private keys, I suggest you keep away from cloud wallets (Exodus saves your keys local).

For AMD card's you'll also need to install the AMDGPU-pro driver with OpenCL support before building Ethminer.

Installing AMDGPU pro driver with OpenCL support

Retrieve the latest drivers from AMD's Support page, then install with OpenCL support and reboot:

# See: https://www.amd.com/en/support
tar -xf amdgpu-pro-*.tar.xz
cd amdgpu-pro-*/
./amdgpu-pro-install --opencl=legacy,pal
reboot

A change is required for Vega10 cards (or newer) , replace legacy,pal with rocm:

./amdgpu-pro-install --opencl=rocm

Optionally, you might add the --headless and/or --no-dkms options to the ./amdgpu-pro-install command if you don't want your desktop environment to load AMD's drivers:

./amdgpu-pro-install --opencl=legacy,pal --no-dkms --headless

Building Ethminer

Manually building Ethminer isn't required at all, it's latest release can simply be downloaded from the releases page. However, if you're boss, and want the extra Hashes from your GPU, build it yourself by following the steps below.

  1. First, install the required drivers for your video card:
    1. For NVidia, use:

      apt-get install nvidia-cuda-toolkit
    2. For AMD, install the driver with OpenCL support first, then use:

      apt-get install opencl-amdgpu-pro-icd
  2. Also, make sure the required packages on your system exist:

    apt-get install cmake mesa-common-dev git

    The mesa-common-dev fixes most build failures.

  3. Now download the latest version from GitHub into a new folder:

    git clone https://github.com/ethereum-mining/ethminer.git
    cd ethminer
    git submodule update --init --recursive
  4. Finally, build it (command's take some time, so be patient):

    • For AMD, use:

      mkdir build; cd build
      cmake .. -DETHASHCUDA=OFF -DETHASHCL=ON
      cmake --build . -- -j
    • For NVidia use:

      mkdir build; cd build
      cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
      cmake --build . -- -j
  5. Optionally you can install as an executable:

    sudo make install

Ethminer's first run

If you've omitted step 5 from above, you can run Ethminer from the ethminer-directory inside the build-directory you're probably still in:

./ethminer/ethminer --help

Otherwise, you can run it directly:

ethminer --help

The commands above show Ethminer's short documentation. For the long documentation, use the --help-ext option, with one of the allowed extensions:

ethminer --help-ext

Optionally, you can have a look at all the options at cpp-ethereum's readme (which is the origin of the ethminer with GPU support).

Benchmarking Ethminer

To get an idea of the MHash/s your setup reaches, you might want to run a benchmark first.

For ATI/OpenCL, use:

./ethminer/ethminer -G -M 0

For NVidia/CUDA, use:

./ethminer/ethminer -U -M 0

If the benchmark returns an empty result (which it probably will the first few times), be patient until the DAG file has been generated.

ethminer benchmark results

Divide the “MAX” hashrate by 1000000 to get the rate in megahashes. This is your real hashrate in MH/s.

Mining with Ethminer

Mining trough Eth.nanopool.org

Finally, we're ready to start mining! The final step is actually very simple, just run the following command:

./ethminer/ethminer -G --report-hr -P stratum1+tcp://0x47e83baffbc118393c082b7d4a62130b0480bb11.rigname@eth-eu1.nanopool.org:9999

Replace 0x47e83BafFbc118393C082B7D4A62130b0480BB11 with your Eth wallet address and rigname with the name of your rig (or just remove it since it's optional).

Now the mining should start to run. Optionally you can monitor your progress by looking up your wallet address on the miner stats page.

Mining trough Other pools

Ethminer supports all latest protocols, allowing you to connect to any pool you want. See the examples on how to connect to different Pools to get started.

Troubleshooting

Getting system information

Some command I've used to get insight on what drivers or devices are recognised or not:

# List GPU's with loaded drivers
lspci -k | grep -EA3 'VGA|3D|Display'

# Show loaded kernel modules
lsmod | grep "kms\|drm\|amdgpu"

# List OpenCL platforms and devices
clinfo

# List devices Ethminer recognises
ethminer --list-devices

Ethminer benchmark keeps giving 0H/s

This mostly happens on CUDA-cards and/or when generating the DAG takes longer than the warmup-time. The --benchmark-warmup option has been removed, so just be patient and let the DAG file generate.

Building Ethminer fails with error #error -- unsupported GNU version! gcc versions later than 6 are not supported!

This error is actually quite self-explanatory, and can be solved my manually setting the gcc version:

# First remove any existing files from the current 'build' directory
make clean

# Now install required libs and restart building
apt-get install gcc-6 g++-6

# For ATI/OpenCL use
cmake -D CMAKE_C_COMPILER=gcc-6 -D CMAKE_CXX_COMPILER=g++-6 -DETHASHCUDA=OFF -DETHASHCL=ON ..
cmake --build . -- -j

# For Nvidia/CUDA use
cmake -D CMAKE_C_COMPILER=gcc-6 -D CMAKE_CXX_COMPILER=g++-6 -DETHASHCUDA=ON -DETHASHCL=OFF ..
cmake --build . -- -j

Ethminer sees no usable devices with AMD card Error: No usable mining devices found

Using clinfo, check to see if any OpenCL-capable platforms are found:

# This is wrong
Number of platforms 0

# This is good
Number of platforms 1
Platform Name AMD Accelerated Parallel Processing
Platform Vendor Advanced Micro Devices, Inc.
Platform Version OpenCL 2.1 AMD-APP (3143.9)
Platform Profile FULL_PROFILE
[...]

If both clinfo and ethminer see no devices, it means the device driver you're using either doesn't work properly or has no OpenCL support. See above on how to install your device's driver. Remove any existing drivers beforehand. Optionally, you can check if AMD's driver is loaded in the kernel using lsmod | grep amdgpu.

SIGSEGV, not enough memory available on device

Look at the lines above the trace message to find out what exactly went wrong. If your device doesn't have enough memory, you might squeeze some extra life out of your card by stopping all other programs, and/or stop your GUI/Desktop environment. Use a DAG size calculator to see the minimal amount of GPU-memory the mining process needs. Using ethminer --list-devices shows the amount of memory that's available.

An alternative solution might be to mine other coins that rely on Ethash Proof of Work, like Expanse or Metaverse.

Other (compatibility) issues

Sometimes, using the latest release results in weird issues or bugs that haven't been fixed yet. Therefore you can checkout an earlier version (for example v0.18.0) and try if that works:

git clone --single-branch --branch v0.18.0 https://github.com/ethereum-mining/ethminer.git

Then follow the same building steps as mentioned above.

Furthermore, it's important to check if there are no conflicting drivers or other issues. For AMD, you might want to manually remove existing drivers:

amdgpu-pro-uninstall
rm -Rf /etc/vulkan /opt/amdgpu /opt/amdgpu-pro

Conclusion

When I started out on Windows 10, my single R9 Nano reached a maximum hashrate of around 22MH/s. After setting up Linux with a prebuilt version of Ethminer the hashrate jumped to nearly 24MH/s. After manually building it, the rate averages just shy of 25MH/s, and if the wheater is cool, slightly above!

Therefore, I must conclude the extra effort on getting the miner and the drivers running is really worth it.

Found this post helpful?

Support us by sending a small tip

Changelog

2019-01-10
Removed eth.pp.ua since it died a long time ago, and use eth.nanopool.org instead. Added commands to ensure GIT submodules are up to date and other fixes in commands to ensure building works again.
2019-01-11
Removed -t 1 flag, since it's not needed. Added --report-hr flag, to report Hashrate to pool. Changed AMD's driver download page to ensure user always get's latest driver release.
2020-09-23
Added -j option to use all cpu cores while building, because it speeds up the process by a lot.
Added documentation on how to install AMDGPU-pro drivers with OpenCL support.
2020-09-24
Added more troubleshooting info, out of memory solution and other minor fixes.
Fixed specifying gcc and g++ version when building.