Mining cryptocurrencies with Ubuntu and sgminer [closed]

What are the steps for setting up a Ubuntu machine for mining of crypto-currencies?

I am looking for a full guide to follow - from installing Ubuntu to how to config and start the miner itself.


Using the procedure outlined below, you should be able to connect 5 or more of your graphics cards to your motherboard's PCIe slots, all at once. I've documented the procedure on how to get the full number of GPUs your motherboard will support, originally because I was having difficulty getting more than 2 cards working consistently (as in: "I'm going to throw this mobo out the window" difficulty).

There are a few good guides available, but they are all missing some information, especially if you have previously installed or experimented with various AMD drivers. The process below combines elements from 3 separate guides (references to original guides included).

The key component in the procedure below is recognizing that we want to install the drivers when all the graphics cards are already attached, since Ubuntu driver installation appears to perform some special initialization that will detect all currently connected graphics cards which very often fail to be detected when adding graphics cards later.

Disclaimer: This procedure should work (in theory) for all motherboards (it would be cool to get some confirmation on this). However, I've tested (ad nauseam) only on the extremely fickle and finicky Gigabyte 990FXA UD5 with 1, 2, 3, 4 and 5 GPUs. (I'm presently waiting for a 6th GPU). Also, I've tested this procedure only on Ubuntu 13.10. But I don't see why it shouldn't work with other Linux variants.

NB: You will need to install ssh and byobu in order to log in remotely to complete this procedure, as your display will be mostly unusable until you install the Ubuntu AMD drivers (see cryptobadger's link below for how to set up ssh and byobu).

Installation Procedure

  1. Disconnect all graphics cards except the main display card. Make sure to disconnect both power connectors (6+8) to each card, and any supplementary power connector if you are using powered risers. Make sure nothing is sitting in any of the other motherboard PCIe slots (not even a PCIe riser).

  2. Remove any Catalyst/fglrx drivers: (Link: Removing Catalyst/fglrx Drivers)

    sudo sh /usr/share/ati/fglrx-uninstall.sh  
    sudo apt-get remove --purge fglrx*  
    sudo apt-get remove --purge xserver-xorg-video-ati xserver-xorg-video-radeon  
    sudo apt-get install xserver-xorg-video-ati
    sudo apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core
    sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
    sudo rm -f /etc/ati  
    
  3. Reconfigure Xorg for good measure: (Link: Reconfigure Xorg)

    sudo dpkg-reconfigure xserver-xorg
    
  4. Shut down your system. Turn off all power supplies. Attach all graphics cards. Turn on all power supplies. Start your system.

  5. Log in remotely via ssh, as your display will be unusable until you install the AMD drivers in the next step (see cryptobadger's link below for how to set up ssh and byobu).

    NB: We want to install the drivers when all the graphics cards are already attached, since driver installation appears to perform some special initialization that will detect all currently connected graphics cards which very often fail to be detected when adding graphics cards later.

  6. Install the Ubuntu AMD Catalyst Drivers (via remote login): (Link: Install AMD Catalyst Drivers)

    sudo apt-get install fglrx-updates fglrx-amdcccle-updates fglrx-updates-dev  
    sudo aticonfig --lsa  
    sudo aticonfig --adapter=all --initial  
    sudo reboot  
    

All connected graphics cards should now be working. Adding additional graphics cards may cause problems after completing this process. If you want to add additional cards, repeat this procedure from the beginning.

Confirmed Configurations

NB: In the configurations below, all USB risers have the presence pin short built in. Also, all risers are powered risers with molex connectors (ribbon and USB).

4 GPUs:

PCIEX1 - x1-to-x16 ribbon riser (no presence pin short)  
PCIEX16_1 - USB riser  
PCIEX16_2 - USB riser  
PCIEX8 - USB riser

PCIEX1 - x1-to-x16 ribbon riser (no presence pin short)  
PCIEX16_1 - USB riser  
PCIEX4_1 - USB riser  
PCIEX16_2 - USB riser

PCIEX16_1 - x1-to-x16 ribbon riser (no presence pin short)
PCIEX4_1 - USB riser
PCIEX16_2 - USB riser
PCIEX8 - USB riser

5 GPUs:

PCIEX1 - x1-to-x16 ribbon riser (no presence pin short)  
PCIEX16_1 - USB riser  
PCIEX4_1 - USB riser  
PCIEX16_2 - USB riser  
PCIEX8 - USB riser (on second power supply w/ dual power supply adapter)  

PCIEX1 - x1-to-x16 ribbon riser (no presence pin short)  
PCIEX16_1 - USB riser  
PCIEX4_1 - USB riser  
PCIEX16_2 - USB riser  
PCIEX4_2 - USB riser (on second power supply w/ dual power supply adapter)  

PCIEX16_1 - x1-to-x16 ribbon riser (no presence pin short)
PCIEX4_1 - USB riser
PCIEX16_2 - USB riser
PCIEX4_2 - USB riser
PCIEX8 - USB riser (on second power supply w/ dual power supply adapter)

PCIEX16_1 - USB riser
PCIEX4_1 - USB riser
PCIEX16_2 - USB riser
PCIEX4_2 - USB riser
PCIEX8 - USB riser (on second power supply w/ dual power supply adapter)

Notes

  • For Gigabyte 990FXA UD5 motherboards, all slots should have the the A1-B17 presence pin short, except the single PCIeX1 slot. The reasoning here is that x1 slots can never be connected to a display (indeed, for Gigabyte 990FXA UD5 motherboards, the BIOS only has options for the 5 full-sized x16 PCIe slots to connect displays as well as the PCI slot).

  • Other motherboards may vary, and if you can connect your display to your motherboard's x1 slots, then you will probably need the A1-B17 presence pin short on these slots also.

  • When in doubt, use the presence pin short on all slots, except for x1 slots (you can buy USB risers with presence pin short built in).

  • Also, the presence pin short is not strictly necessary for the x16 slot that will be connected to the main display (since a display is already 'present').

  • If this procedure doesn't work for you, repeat from the beginning until it does (sometimes up to several times). Running the command "sudo aticonfig --adapter=all --odgt" after the last reboot should show the temperatures for all the graphics cards it can see and mine. If it gives an error for any of them, repeat the procedure from the beginning.

  • It is extremely important to follow the first step religiously. I started getting lazy, and just turned off the power supplies and began to encounter all kinds of problems. You must physically disconnect all power connectors from all graphics cards (including any supplementary power connectors if you are using powered risers). Also, be sure to disconnect all risers from the PCIe slots.

Acknowledgements

Thanks to everyone in the forums for sharing the knowledge.

Good luck.

P.S. If this guide has made your day, here are some donation addresses:

BTC: 1KpJUM1HawSybFRVQiJDEbFK2tRZGL9qNU
LTC: Li4D9pDNMq4zznAjXPfM7FM952a9sXEKN4
FTC: 6kx533kXn5dZuALtHp7XesC9L3iuFndw93
VTC: Vd51sDofvGhr3EGpwAN2xSppuyotJQFFPq


According to release notes of "AMD Catalyst™ 13.12 Proprietary Linux x86 Display Driver" the driver is supporting Ubuntu 12.04.2 and 13.04. Since, Ubuntu 13.04 is not supported already, you need to install Ubuntu 12.04.2 (I have not tested the solution with Ubuntu 12.04.4 and can not guarantee it will work).

The reason I am not using "AMD Catalyst™ 14.2 LINUX Beta Driver" driver that is supporting Ubuntu 12.04.3 and 13.10 is because it is not stable (after all it is in beta) and a lot of miners are having issues with it.


  1. Downloading and installing Ubuntu 12.04.2

    a) the 12.04.2 build can be found here http://old-releases.ubuntu.com/releases/12.04.2/

    b) there are a tons of tutorials how to make a bootable USB stick with Ubuntu - just check the internet

    c) a lot of people (including me) have troubles installing the Ubuntu on machine without build-in video card - you should be able to found solution here - My computer boots to a black screen, what options do I have to fix it?

  2. Disable future Ubuntu builds

    According releases notes of "AMD Catalyst™ 13.12 Proprietary Linux x86 Display Driver" the driver is supporting Ubuntu 12.04.2 and 13.04, so I disable the Ubuntu future builds leaving the security updates only.

    Note, that some folks believe the driver should work with next builds, too, but I have not test it.

    If you do not know how to disable the builds check the following topic - How to download and install specific Ubuntu version and disable future builds?

  3. Installing drivers dependencies

    sudo apt-get install build-essential cdbs dh-make dkms execstack dh-modaliases linux- headers-generic fakeroot libqtgui4 lib32gcc1

  4. Downloading latest AMD Catalyst drivers

    AMD Catalyst Linux driver supports most AMD Radeon graphic cards including HD7950, HD7970, R9 280X, R9 290, R9 290X, and many more.

    Note: In our case we are downloading the latest stable version.

    a) open http://support.amd.com/en-us/download b) select your options (the screenshot below displays my case)

    enter image description here

  5. Installing the driver

    cd Downloads sudo unzip amd-catalyst-14.1-betav1.3-linux-x86.x86_64.zip sudo sh .run --buildpkg Ubuntu/raring sudo dpkg -i fglrx.deb

  6. Seting your GUI to use the new AMD Radeon graphic cards:

    sudo aticonfig --initial -f --adapter=all sudo reboot

  7. Installing sgminer dependencies:

    sudo apt-get update sudo apt-get install aptitude sudo aptitude install libcurl4-openssl-dev

    sudo apt-get install autoconf opencl-headers libcurl4-openssl-dev libtool libncurses5-dev

  8. Downloading sgminer

    cd Downloads/Ubuntu/sgminer wget https://github.com/veox/sgminer/archive/4.1.0.tar.gz tar -xf 4.1.0.tar.gz cd sgminer-4.1.0

    Note: Check if newer version is available

  9. Downloading display library (ADL) SDK

    Downloading display library (ADL) SDK “ADL_SDK_6.0.zip” and Unzip and copy files from include/* to
    sgminers/ADL_SDK/ folder:

    http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/

  10. Installing sgminer

    libtoolize autoreconf -ivf CFLAGS="-O2 -Wall -march=native" ./configure sudo make install

  11. Listing your devices:

    sgminer -n

Sources:

http://blog.shindasingh.com/2014/01/sgminer-4-0/
http://highoncoins.com/litecoin-rig/how-to-install-ubuntu-and-optimize-cgminer-for-litecoin-mining-rig/
https://github.com/veox/sgminer
http://support.amd.com/en-us/kb-articles/Pages/amdcatalyst13-12linreleasenotes.aspx
http://support.amd.com/en-us/kb-articles/Pages/Latest-LINUX-Beta-Driver.aspx