Compiling CGMiner on Fedora 19 with AMD Catalyst Drivers

Below is a guide to get cgminer compiled and working on Fedora 19 with scrypt using the AMD Catalyst and OpenCL drivers.

First, you will need to enable the RPMFusion Repo for the AMD Catalyst drivers.

sudo rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-19.noarch.rpm
sudo rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-19.noarch.rpm

Then, you will need to yum install the AMD Catalyst driver and some other needed libraries.

sudo yum -y install curl-devel automake gcc ncurses-devel kmod-catalyst

You should reboot after installing the AMD binary drivers and then run the following command if you have multiple amd cards to get them into the Xorg config.

sudo DISPLAY=:0 aticonfig -f --initial --adapter=all

You will want to reload X or reboot after running that command to load the changes.

Grab the AMD-APP-SDK from here: http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/

Then use the below commands to install it.

tar -xvzf AMD-APP-SDK-v2.9-lnx64.tgz
sudo ./Install-AMD-APP.sh

The installer now creates files in /etc/ld.so.conf.d to load the libraries.  I think you may be able to trigger this with the ldconfig command, but a reboot definitely reloads it.

Grab the latest AMD-ADL-SDK from here: http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/

Then in the same directory where you downloaded the ADL_SDK zip file, run the below commands:

wget http://ck.kolivas.org/apps/cgminer/3.7/cgminer-3.7.2.tar.bz2
tar -xvjf cgminer-3.7.2.tar.bz2
unzip -j ADL_SDK_*.zip include/*.h -d cgminer-3.7.2/ADL_SDK/
cd cgminer-3.7.2
./configure --enable-scrypt --enable-opencl
make
sudo make install

Now, you should have cgminer installed and ready to run using your AMD videocard.  Run the below command to test that it sees your videocard and everything.

sudo /usr/local/bin/cgminer -n

If you are running this over SSH, you may need to export the display as part of the command.

DISPLAY=:0 sudo /usr/local/bin/cgminer -n
Advertisements
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

55 Responses to Compiling CGMiner on Fedora 19 with AMD Catalyst Drivers

  1. Charlie Root says:

    I followed these instructions but the autogen.sh always says

    configure: error: No mining configured in

    It’s like it’s not seeing that opencl is there.

    Any ideas?

  2. Charlie Root says:

    I’m not sure if I rebooted after installing the binary drivers or not.

    So, I just rebooted and then restarted the instructions at the AMD-APP-SDK.

    As a note, I’m using 32bit FC19. In your instructions you have to manually create some links…

    > sudo ln -s /opt/AMDAPP/include/CL /usr/include/
    > sudo ln -s /opt/AMDAPP/lib/x86_64/* /usr/lib64/

    I can’t make the second one so I changed it to sudo ln -s /opt/AMDAPP/lib/x86/* /usr/lib/

    After proceeding through the remaining instructions I’m still at the same error msg.

    • meltingrobot says:

      Yeah, I did it on 64-bit, but the paths you put look correct for 32-bit. A couple of things to possibly check, I noticed that they now have version 6 of the AMD-APP-SDK, so you may want to Google to see if other people had issues with that version(I’m assuming that’s the version you grabbed). Or if you grabbed the older version, see if cgminer requires the new version now. Also, do a “lsmod | grep fglrx” to see if you are running the AMD binary driver now instead of the radeon driver that comes with the kernel.

  3. Charlie Root says:

    [root@localhost cgminer]# lsmod | grep fglrx
    fglrx 6463576 48

    [root@localhost cgminer]# aticonfig –list-adapters
    * 0. 03:00.0 AMD Radeon HD 7900 Series

    * – Default adapter

  4. Charlie Root says:

    Thx, I’ll get 2.8 and try again. Anything I should do to remove 2.9 before trying 2.8?

  5. Charlie Root says:

    Still at the same spot. Grrrrr…. looks like I might have to resort to running this on a Windows box.

    • meltingrobot says:

      I’m sorry you are having issues. I will try to rebuild my box at home and throw an AMD card into it this weekend and re-run through the steps I posted to see if anything changed.

  6. Charlie Root says:

    This might be the problem from ldconfig.log

    /lib:
    ldconfig: Cannot stat /lib/libamdocl32.so: No such file or directory
    ldconfig: Cannot stat /lib/libOpenCL.so: No such file or directory

  7. meltingrobot says:

    Hmm, did you remove the symlinks from the old one? Also, did you re-run the sudo ln -s /opt/AMDAPP/lib/x86/* /usr/lib/ and sudo ln -s /opt/AMDAPP/include/CL /usr/include/ after installing 2.8?

  8. Charlie Root says:

    Could you be specific on the symlinks I should remove?

    I did re-run the two link commands from the instructions.

  9. meltingrobot says:

    Hmm, do a “sudo updatedb” followed by a “sudo locate libOpenCL.so” to see if that file exists where it should. It’s odd that it is looking for the file in /lib/ instead of /usr/lib

  10. Charlie Root says:

    [root@localhost cgminer]# sudo updatedb
    [root@localhost cgminer]# sudo locate libOpenCL.so
    /usr/lib/libOpenCL.so
    /usr/lib/catalyst/libOpenCL.so.1

    • meltingrobot says:

      Looks like the file is installed in the correct location, not sure why ldconfig is looking for it in /lib. You may want to try clearing out the cgminer source folder and pulling it back down from git and see if that helps.

  11. Charlie Root says:

    Remove cgminer dir and pulled it back from git. Same thing.

    • meltingrobot says:

      Looks like some people have had to define CFLAGS and LDFLAGS when compiling. You may want to try this. Change the AMD-APP-SDK directories to match what yours are.

      CFLAGS=”-O2 -Wall -march=native -I/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/include” LDFLAGS=”-L/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/lib/x86″ ./configure –enable-scrypt

  12. Charlie Root says:

    With that command line I get an error about gcc not working..

    checking whether the C compiler works… no
    configure: error: in `/root/temp/cgminer’:
    configure: error: C compiler cannot create executables

    I’ve checked to make sure I’m not missing any glibc packages but I haven’t googled the correct fix to this one yet.

  13. Charlie Root says:

    If I use the command

    CFLAGS=”-I/opt/AMDAPP/include”” LDFLAGS=”-L/opt/AMDAPP/lib/x86″ ./configure –enable-scrypt

    I don’t get the gcc error. I didn’t read the man page to see what -O2 -Wall -march=native does. Maybe x64?

    • meltingrobot says:

      That may be it. I don’t think it’s necessary at all anyways. Did things fully compile out without it?

    • -O2 is a form of general software optimization for the binary and is standard for GCC and G++.

      -Wall, means, display all warning as errors, in other words, it won’t compile and link if you have any errors in your source or object code.

      -march=native, Is a form of specifying all the optimizations of the hardware the software is compiling and linking on.

      Note:

      Above all, make sure you have the equivalent of the dependencies instead in Fedora installed first before you even begin to install this other stuff. Read the README for CGMiner 3.7.2, those are Ubuntu dependencies but some of them are universal and can be had from external sites.

      Make sure you have the latest glibc installed (6.0 or higher), have gcc and g++ installed as well. Make sure that you install the full ATI package; driver and catalyst. There are things that are neccessary as a part of the Catalyst installation that can’t be controlled via cgminer unless it’s installed.

      cgminer’s ADL include files reference certain commands that are available to ATI Catalyst directly and affect the performance of the card in more ways than one. Such as fan speed, for example. One of many functions are implemented in Catalyst which aren’t stock in just the restricted driver.

      When installing the restricted ATI drivers, you will need to issue this command before you reboot. (this is assuming you only have one ATI video card in your system, if you have more than one, take a look at the ATI wiki for ATI Catalyst).

      sudo aticonfig -f –initial

      Download AMD APP SDK v2.9 for your appropriate architecture and software environment, meaning if you have a 32-bit Linux OS download the 32-bit version and if you have 64-bit download that version.

      sudo ./Install-AMD-APP.sh

      Make sure to reboot after you do this (as per it’s request)

      Download AMD ADL 7

      Make sure you have all your dependencies met, that you take the ADL library includes (3 files in there and copy them to the CGMiner 3.7.2 folder for ADL). It will be listed as such, “cgminer-3.7.2/ADL_SDK”.

      The ADL and APP libraries go hand in hand, if you get the wrong version in your system, you will have trouble, not just with cgminer, itself but anything else that uses those libraries.

      ./configure –enable-opencl –enable-scrypt

      If everything goes right.

      Then do what it says.

      sudo make install

      (By the way, you don’t need to use the extra make before the “sudo make install”, ./configure does it for you.) Sure you need to fix the source code and redo something
      such as compiling, when you’re in the cgminer main directory, issue this.

      make clean

      What this does is delete all your object files and other stuff that was done in the initial compiliation and linking process, it’s like starting anew.

      Then you issue the ./configure –enable-opencl –enable-scrypt
      again. Hit enter and wait…

      Here is the thing, if you want to use GP-GPUs with CGMiner you need up to v3.7.2 because anything beyond that (with the forked exception of 3.7.3 and 3.7.4 not by the original author) will need “Open CL” specified to be enabled. Now, there is another requirement if you want to use GP-GPUs, which at first glance makes no sense.

      If you want to compile it for use with GP-GPU cards or embedded chips that can use OpenCL you need to also use the –enable-scrypt switch too, even if you’re not using the S-Crypt algorithm and just use one of the 4 SHA256D algorithms.

      If you’re just doing Bitcoins, by far, the poclbm kernel is the best and gives the most consistent hashrate.

      The last official CGMiner to use GP-GPUs is 3.7.2 but isn’t the last to use S-Crypt algorithm, as there are FPGAs and ASICs that now do S-Crypt (scypt) algorithms but don’t use OpenCL as a means to calculate it. The forked 3.7.3, 3.7.4 and SGMiner series all still use GP-GPUs and have the ability to use S-Crypt.

      SHA256D and S-Crypt are ways of calculated hashes.

      Getwork, GBT and Stratum protocols are ways to get and send data from the servers or pools (also known as proof-of-work).

      I hope this clears up any confusion of what these terms mean.

      If you’re a newbie and don’t want a lot of hell when working with cgminer 3.7.2 but want to stay in Linux, I would stay with Ubuntu, since that is what it was designed for, grab Ubuntu 14.04 32 or 64 bit depending on your processor and system type. Reading the “README” file gives a lot of information you need for that distribution and how to install.

      If you want to tough it out on Fedora, that’s you’re choice, expect quite a few bumps in the road with this software. Granted, there is nothing wrong with using CGMiner 3.7.2 on Fedora it’s just not “designed for it”, it’s designed for Ubuntu Linux. Perhaps someone could create a package for it in RedHat, CentOS and Fedora (to make it easier to install and get all the dependencies met).

      While I could do it, I am primarily on Slackware, PCLinuxOS and Ubuntu (still on Gentoo on occasion, as well).

      The compiler flags are in fact “all” necessary. If they weren’t, they wouldn’t be there. Think about that for a little while.

  14. Charlie Root says:

    Compiled without those options but still gives the same error.

    configure: error: No mining configured in

    I’m going to wipe the system and start fresh in case I did something wrong. BTW, git isn’t part of the default install so it should be included in your yum install instructions too.

    Thanks

  15. Charlie Root says:

    Yeah good point, I’m pretty sure this old AMD cpu is 64bit.

  16. Charlie Root says:

    Just wanted to let you know if I have the x64 installed and running.

    I get the following when trying to use yum now from all mirrors. Google says this has happened before and I just need to wait a few hours.

    http://dl.fedoraproject.org/pub/fedora/linux/updates/19/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for updates

  17. Charlie Root says:

    cgminer release 2.7.xx is the last version to support scrypt. I have been using 2.8.xx so I’ll see about using an older version. You’ll have to change the git clone instructions so it doesn’t grab the latest version.

  18. Charlie Root says:

    There isn’t an autogen.sh unless you use git.

    This line works with default locations

    CFLAGS=”-O2 -Wall -march=native -I/opt/AMDAPP/include” LDFLAGS=”-L/opt/AMDAPP/lib/x86_64″ ./configure –enable-opencl

    Thanks

  19. Charlie Root says:

    I gave up for now. Cgminer compiles with scrypt support but still says no gpu detected.

    • meltingrobot says:

      Hi Charlie, I finally got a chance to reinstall my system and work on this. Apparently, you now need to compile cgminer and tell it to do opencl specifically. I’m updating the instructions now.

      ./configure –enable-scrypt –enable-opencl

  20. Charlie Root says:

    Hi, I decided to retry this. I get cgminer to compile and it says opencl/scrypt is working

    OpenCL……………: FOUND. GPU mining support enabled
    scrypt……………: Enabled
    ADL………………: SDK found, GPU monitoring support enabled

    cgminer still reports…

    [root@localhost cgminer-3.7.2]# ./cgminer -n
    No protocol specified
    [2013-11-28 12:26:10] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-11-28 12:26:10] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-11-28 12:26:10] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2013-11-28 12:26:10] Error -1: Getting Device IDs (num)
    [2013-11-28 12:26:10] clDevicesNum returned error, no GPUs usable
    [2013-11-28 12:26:10] 0 GPU devices max detected

    [root@localhost cgminer-3.7.2]# aticonfig –list-adapters
    * 0. 03:00.0 AMD Radeon HD 7900 Series

    [root@localhost cgminer-3.7.2]# lsmod | grep fglrx
    fglrx 6962044 46
    amd_iommu_v2 18701 1 fglrx

  21. Charlie Root says:

    Oh, I had to make those two manual links for cgminer to compile with opencl and srcypt.

  22. Charlie Root says:

    I did a yum reinstall kmod-catalyst and rebooted and now I get this…

    [root@localhost cgminer-3.7.2]# ./cgminer -n
    [2013-11-28 13:02:34] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-11-28 13:02:34] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-11-28 13:02:34] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2013-11-28 13:02:34] Platform 0 devices: 1
    [2013-11-28 13:02:34] 0 Tahiti
    [2013-11-28 13:02:34] ADL Initialisation Error! Error -1!
    [2013-11-28 13:02:34] 1 GPU devices max detected

    Looks like we made it!!!

    Thanks

    • meltingrobot says:

      Glad to hear. Good luck with your scrypt mining.

    • You need to pay attention to the ADL error, it didn’t initialize properly. Need to get the correct version of the APP SDK and the ADL SDK matched and installed. Make clean and then do the configure again.

      There is something else that needs to be known.

      ATI Catalyst’s overdrive features to be enabled means you need to use
      sudo aticonfig -f –initial (same thing as “sudo amdconfig -f –initial”).

      The reason for this is, ATIconfig needs to be able to write values to a system file that didn’t exist before.

      ADL requires ATI Catalyst to be installed and fullly functioning, therefore, you need to do that aticonfig thing. Whole bunch of steps involved, just to get it working. (correctly) :))

      ADL controls the speed of the GP-GPU, speed of the memory on the graphics card, the fan(s) speed in percentile, powertune in percent, overvolting the GPU for stability, etc. All monitoring of the enviromental controls on the card is also needs ADL to be working correctly.

      Your card might run but can crash unexpectedly or will get very poor hash rates.

  23. Charlie Root says:

    OMG, rebooted and now cgminer says 0 gpus

  24. Charlie Root says:

    If reboot I have to run cgminer once locally before I can run it over ssh even if I use DISPLAY=:0

  25. Charles Fuller says:

    Thanks a lot for this guide. I’ve been working on getting this installed using the latest version (3.8.5) but I didn’t see that GPU mining was removed at 3.8 so I was getting errors in compilation. I thought you specified 3.7.2 because it was the latest version out when you wrote this. Whoops! Anyway, thank again for the time you put into this article. It’s saved me some headache.

  26. root says:

    I can’t run it over ssh. On localhost all OK with start X server. But if i connect over ssh
    [root@localhost ~]# DISPLAY=:0 cgminer -n
    No protocol specified
    [2013-12-22 23:42:28] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-12-22 23:42:28] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-12-22 23:42:28] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2013-12-22 23:42:28] Error -1: Getting Device IDs (num)
    [2013-12-22 23:42:28] clDevicesNum returned error, no GPUs usable
    [2013-12-22 23:42:28] 0 GPU devices max detected
    ———————-
    any idea? 🙂
    PS
    Thanks for manual!

  27. wzis says:

    I followed your procedure on both Fedora 17 and Fedora 19, but found a problem:
    on Fedora 17, it installed kernel version 3.9.5 and the fglrx module for that kernel, and after reboot, X window unable to start.
    On Fedora 19, it installed kernel 3.12, and the fglrx module for this kernel, and again, after reboot, X window not able to start.
    When tried to use “insmod fglrx.ko”, it said device not found. So, something is wrong.

    • meltingrobot says:

      What model is your AMD card? Some older models aren’t supported by the fglrx driver.

      • wzis says:

        It’s R9 290. I also just retried again by refresh install the F19 live, get rpmfussion repo, remove those update and rawhide ones, run the yum install xxxx kmod-catalyst, reboot the machine. But again, X window failed to start. When insmod fglrx, got “No such device.”

    • meltingrobot says:

      Hmm, not sure what is going on there. Since it’s a newer card, I suppose it’s possible that the card may not yet be supported with the version of the Catalyst driver that RPMFusion is compiling. It may start working with an update, or you may have better luck with the akmod-catalyst package.

  28. Joe says:

    Thanks for this awesome guide. Pretty smooth sailing for me. After setting this up, how do I start mining? Do I need a LTC client wallet installed and then run the cgminer? Thanks in advance!

  29. death says:

    pfeww… thx a lot for this.

    managed to get it all going on a fc 19 live usb stick with overlay 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s