Friday, October 4, 2013

Minimal Headless OpenCL + cgminer on Ubuntu 13.04 Server

Purpose of this Guide
I'm going to explain how to set up a minimal number of X dependencies required to run cgminer on Linux with AMD GPUs. This also potentially applies to other OpenCL tasks too.

Why is this Needed?
AMD makes decent Windows drivers, but unfortunately, AMD's proprietary Linux drivers are not very good. In order to do OpenCL, you must have some sort of X server running*.

*Update: there is a way to modify the drivers so that an X server isn't required: http://devgurus.amd.com/thread/168273
I could not get it to work, but one of the commenters reported success (but only with errors and no ADL)

Assumptions
I'm going to assume you've got a headless server with SSH access and that you've just done a default install of Ubuntu Server 13.04 64-bit.

Note about Ubuntu Desktop vs Ubuntu Server:
It's very likely that the instructions in this guide will not work with Ubuntu Desktop without a few modifications. This guide will install xdm and assume it's set as the default, but if you already have a graphical environment, you probably already have a display manager installed (probably lightdm).

Also, there have been varying levels of success with different software versions. Some combinations of fglrx and the APP-SDK result in 100% CPU usage, or just don't work at all.



Update the Server
It's very important that you run apt-get update otherwise the buildpkg may fail later. Also, upgrading now is a good idea unless you want to experience the pain of upgrading a kernel with fglrx right away.
sudo apt-get update
sudo apt-get dist-upgrade
sudo reboot

Download and Install the Drivers
Download the latest fglrx drivers (I'm using 13.8 beta in this guide):
(note: at least one commenter reported problems with the latest drivers. If you need 13.8 specifically, see Patrick's commentuse "wget --referer="http://www.amd.com" http://www2.ati.com/drivers/beta/amd-catalyst-13.8-beta2-linux-x86.x86_64.zip" to download because AMD blocks direct links)
(note: if you have an R9 290 or one of the other newer GPUs, please see this comment, there are several people having trouble with the newer cards, you might need to install a graphical environment first and run the manual installer rather than building a package)
http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx

Install Some Necessary Packages
sudo apt-get install dh-make dh-modaliases execstack libxrandr2 libice6 libsm6 libfontconfig1 libxi6 libxcursor1 libgl1-mesa-glx libxinerama1 libqtgui4 unzip

Extract the Installer
unzip amd-catalyst-13.10-beta2-linux-x86.x86_64.zip
chmod +x amd-catalyst-13.10-beta2-linux-x86.x86_64.run

Build the fglrx .deb Packages
./amd-catalyst-13.10-beta2-linux-x86.x86_64.run --buildpkg Ubuntu/raring

(replace "raring" with the code name for your version according to "lsb_release -c")

Install fglrx
sudo dpkg -i fglrx*.deb
sudo apt-get -f install
sudo reboot
(it'll fail the first time, complaining about dependency problems; running apt-get -f install fixes it)

If you have multiple GPUs and want to run all of them, you might have to run something like: Update: it looks like this step is required. You can also run "aticonfig --list-adapters" if you'd like some extra information.
sudo aticonfig --initial --adapter=all

Install the APP SDK
Next, you'll need AMD's APP SDK:

Extract the APP SDK
tar xvf AMD-APP-SDK-v2.8.1.0-lnx64.tgz
sudo ./Install-AMD-APP.sh
sudo reboot

(you can do this in another directory if you want, these things produce lost of junk files)

Install the Minimum Required X Server Packages
sudo apt-get install xdm xorg

If you have a screen hooked up, you'll see an ugly XDM log in prompt. Don't use it (unless you install openbox or something). If you need console access to your server, switch to tty1 (ctrl+alt+f1).

Disable Authorization on xdm
(if you know of a better way to do this, please tell me...)

sudo nano /etc/X11/xdm/xdm-config

find the line
DisplayManager*authorize:       true

and make it
DisplayManager*authorize:       false

Save the file and reboot
sudo reboot

At this point, I'd recommend making sure xdm is actually running.

Compile cgminer and Test
Even if you don't plan to mine crypto-currencies, running cgminer is a good way to make sure stuff works. If you just want to run your own application, take a look at the cgminer sh towards the end and modify it to your needs.

Install Git
sudo apt-get install git

Download cgminer
git clone -b 3.7 https://github.com/ckolivas/cgminer
Update: It looks like cgminer 3.7.2 is the last version to support GPU mining (see: https://bitcointalk.org/index.php?topic=28402.msg3538435#msg3538435). Thank you to the Anonymous poster in the comments for this.

Alternatively, you could try sgminer, a scrypt-only fork of cgminer 3.7.2 with new bug fixes, as suggested by an anonymous comment.
http://www.reddit.com/r/litecoinmining/comments/1va8g2/ann_sgminer_400_release/
https://github.com/veox/sgminer

Download AMD ADL SDK (for temperature monitoring, fan control, etc)
unzip ADL_SDK_5.0.zip
cp include/* ./cgminer/ADL_SDK/
(you might want to do this in a temporary directory as the ADL zip has a bunch of other stuff that it extracts into the current directory)

Install the packages we'll need to compile cgminer
sudo apt-get install build-essential autoconf libtool libcurl4-openssl-dev libncurses5-dev pkg-config libudev-dev

Compile cgminer
cd cgminer
./autogen.sh
./configure --enable-opencl --enable-scrypt
Update: It seems that I now have to add --enable-opencl to compile on 3.7.2
Note: you only need "./configure" (without any options) if you're using sgminer

Make sure you see the following after configure:
OpenCL...............: FOUND. GPU mining support enabled
scrypt...............: Enabled
ADL..................: SDK found, GPU monitoring support enabled

If everything looks good, compile
make

Testing cgminer (or other OpenCL applications)
You'll need to set some environment variables to run OpenCL applications. I recommend you start them with a bash script like the following:
#!/bin/bash
export DISPLAY=:0
export GPU_MAX_ALLOC_PERCENT=100
export GPU_USE_SYNC_OBJECTS=1
./cgminer -n

Save it as something like "test.sh" and "chmod +x test.sh"

(note: in some cases, you may need to run the script as root)
When you run it, you should get something like:
 [2013-10-04 22:46:09] CL Platform 0 vendor: Advanced Micro Devices, Inc.                    
 [2013-10-04 22:46:09] CL Platform 0 name: AMD Accelerated Parallel Processing                    
 [2013-10-04 22:46:09] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)                    
 [2013-10-04 22:46:09] Platform 0 devices: 1                    
 [2013-10-04 22:46:09] 0 Tahiti                    
 [2013-10-04 22:46:09] GPU 0 AMD Radeon HD 7900 Series hardware monitoring enabled                
 [2013-10-04 22:46:09] 1 GPU devices max detected

If everything worked (hopefully it did, because if not, the suffering starts now), you can now run OpenCL applications. Yay!

If you found this guide helpful and want to donate:
BTC -- 1EBVjJSM7Qa1msYcU4AEFG3kLFimwXbAA9
LTC -- LQNDRwrk9H6nwU88Ka87XPqfiJ9AAqdxJR
BQC -- bXigfHpF6qsGYANjJUSc58bRWDAcruVEUE

Issues / Troubleshooting

If something in this guide didn't work for you, please leave a comment with your operating system and driver version. I ran through this guide start to finish on a fresh install on my hardware and it seemed to work, but I only have a 7950 to test.

Some people are having issues with R9 290s. It looks like there are problems getting cgminer to see the newer hardware in some cases. I don't have any new hardware to test unfortunately, but I linked a few of the comments above, it seems a few people managed to figure it out.

Also, since GPU mining isn't supported in the newer cgminer releases, this guide may no longer work when AMD releases new hardware.

Run cgminer at Boot with rc.local and screen

This is a simple workaround to get cgminer running at boot and allow you to see it when you log in remotely later. These are not complete instructions, but hopefully they might help.

First, install screen if you haven't already:

sudo apt-get install screen

If you use a script like my test.sh script above to start cgminer already, then take note of where that is located. Create a different script somewhere accessible (mine is ~/boot.sh in my home directory) and add this:

#!/bin/bash
cd /home/yourusername/cgminer/
/home/yourusername/cgminer/run.sh
(of course replace "yourusername" with your name, and "run.sh" with whatever script you use to start cgminer)

Then add something like this to your rc.local

/bin/su yourusername -c "/usr/bin/screen -dmS test bash -c '/home/yourusername/boot.sh; exec bash'"

To test, log in as the root user "sudo su" and run "/etc/rc.local". Exit the root user, and run "screen -r" and see if cgminer is working. To detach from screen, type Ctrl+a then type 'd' key. Then try it after a reboot.

Alternatively, one commenter mentioned using crontab, which may be better than the rc.local method.

Run "crontab -e" (as a regular user, not root) and add something like the following:

@reboot cd /home/yourusername/cgminer && screen -dmS test bash -c '/home/yourusername/cgminer/run.sh; exec bash'

That seemed to work for me. Probably a better solution since it doesn't require root.

81 comments:

  1. I have two 7970's, and I cannot get any kind of confirmation of OpenCL working when I run "./configure --enable-scrypt". Also, "--enable-scrypt" doesn't seem to be a thing any more. Running "clinfo" I see my processor and my two video cards. Any clues as what to do to get cgminer to see them?

    ReplyDelete
    Replies
    1. yeah they seem to have disabled scrypt in recent versions, no idea why. If you use 'git checkout tags/3.1.1' after cloning the repo you shouldn't have any issues compiling. I don't know at which version they stopped including scrypt but I know that one works.

      Delete
  2. Which version of cgminer are you trying to use?
    I'm asking because last version of cgminer that supports GPU mining is 3.7.2:
    https://bitcointalk.org/index.php?topic=28402.msg3538435#msg3538435

    ReplyDelete
  3. Everything seems to have built and installed properly but when I run ./cgminer -n I get:

    Setting of real/effective user Id to 0/0 failed
    libkmod: ERROR ../libkmod/libkmod-module.c:791 kmod_module_insert_module: could not find module by name='fglrx'
    ERROR: could not insert 'fglrx': Function not implemented
    Error! Fail to load fglrx kernel module! Maybe you can switch to root user to load kernel module directly
    X Error of failed request: BadRequest (invalid request code or no such operation)
    Major opcode of failed request: 154 ()
    Minor opcode of failed request: 19
    Serial number of failed request: 12
    Current serial number in output stream: 12

    ReplyDelete
    Replies
    1. I found the issue, looks like the latest version of amd-catalyst drivers do not include required files, must use your recommended version of 13.8-beta

      Delete
    2. Ah, interesting. Was it 13.11 that didn't work?

      Delete
    3. Where do you find the 13.8-beta? I can't find it in the archives.

      Delete
    4. http://www2.ati.com/drivers/beta/amd-catalyst-13.8-beta2-linux-x86.x86_64.zip

      Delete
    5. I noticed that you cannot download the 13.8 driver file from AMD's web site directly using the URL because AMD blocks direct and external requests to the download pages. In order to download the file, you need to spoof the HTTP referrer. You should be able to download it with the following command:
      wget --referer="http://www.amd.com" http://www2.ati.com/drivers/beta/amd-catalyst-13.8-beta2-linux-x86.x86_64.zip

      Delete
    6. I've struggled for a day or two with my system setup (R9290X, HD7850, I7-4820, 16GB RAM @ Xubuntu) and after the n-th re-install it started working.

      AMD Driver: 13.11 (latest). Installed the driver without the --buildpkg Ubuntu/$(lsb_release -c) option in a desperate attempt to "try everything", which lead me to a install screen asking if I wanted the latest driver (13.20) which I approved...

      All else I did as described in the post with the following versions,

      CGMINER 3.7.2
      AMD ADL SDK 6.0
      AMD-APP-SDK-v2.9-lnx64.tgz

      Good luck

      Delete
    7. I almost got it working thanks to your instructions... only think is I am getting 41.08Kh/s with a r9 290!

      [2013-12-14 05:41:34] Started cgminer 3.7.2
      [2013-12-14 05:41:34] ADL found less devices than opencl!
      [2013-12-14 05:41:34] There is possibly more than one display attached to a GPU
      [2013-12-14 05:41:34] Use the gpu map feature to reliably map OpenCL to ADL
      [2013-12-14 05:41:34] WARNING: Number of OpenCL and ADL devices did not match!
      [2013-12-14 05:41:34] Hardware monitoring may NOT match up with devices!

      Delete
    8. Fixed the above problem by reinstalling the fglrx package after removing all.

      Now is card is detected and there are no more errors but I am mining at
      GPU 0: 68.0C 1059RPM | 19.09K/19.43Kh/s | A:239 R:0 HW:0 WU:18.0/m I:10

      Delete
    9. "GPU 0: 68.0C 1059RPM | 19.09K/19.43Kh/s | A:239 R:0 HW:0 WU:18.0/m I:10"

      Try raising the intensity to 20.

      Delete
  4. Everything compiles correctly. Can't get it to work. Used these instructions and some from other sources. Any ideas?

    kurt@miner01:~/Downloads/cgminer-3.7.2$ export DISPLAY=:0
    kurt@miner01:~/Downloads/cgminer-3.7.2$ export GPU_MAX_ALLOC_PERCENT=100
    kurt@miner01:~/Downloads/cgminer-3.7.2$ export GPU_USE_SYNC_OBJECTS=1
    kurt@miner01:~/Downloads/cgminer-3.7.2$ ./cgminer -n
    [2013-12-03 12:26:53] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-12-03 12:26:53] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-12-03 12:26:53] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2013-12-03 12:26:53] Error -1: Getting Device IDs (num)
    [2013-12-03 12:26:53] clDevicesNum returned error, no GPUs usable
    [2013-12-03 12:26:53] 0 GPU devices max detected
    [2013-12-03 12:26:53] USB all: found 12 devices - listing known devices
    [2013-12-03 12:26:53] No known USB devices

    ReplyDelete
    Replies
    1. I get the exact same problem, on 13.10, with a r9 290 gpu using newest drivers (13.11)...

      Delete
    2. I get the EXACT same issue with R9 290s, tried SlackWare and Xubuntu. I'm just about to give up and go to Windows

      Delete
    3. It sounds like a communication problem with the X server.
      If you run "lspci | grep VGA" and "cat /etc/X11/xorg.conf | grep BusID", do the numbers match up?

      Delete
    4. Same issue here... r9 290 13.11 clinfo shows only cpu

      Delete
    5. this is what I get:

      > lspci | grep VGA
      01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii PRO [Radeon R9 290]
      > cat /etc/X11/xorg.conf | grep BusID
      BusID "PCI:1:0:0"

      looks like they match up, no?

      Delete
    6. It must be a problem unique to the newer generation of GPUs. I unfortunately do not have an R9 290 to test. I found several threads through Google with similar problems, a few of them suggested removing the APP SDK since the latest drivers supposedly have it included (but I thought that only applied to Windows, maybe that's not true anymore).
      http://devgurus.amd.com/message/1301419#1301419

      Delete
    7. getting this problem with 290 R9

      [2013-12-14 04:46:55] CL Platform 0 vendor: Advanced Micro Devices, Inc.
      [2013-12-14 04:46:55] CL Platform 0 name: AMD Accelerated Parallel Processing
      [2013-12-14 04:46:55] CL Platform 0 version: OpenCL 1.2 AMD-APP (1307.1)
      [2013-12-14 04:46:55] Platform 0 devices: 1
      [2013-12-14 04:46:55] 0 Hawaii
      [2013-12-14 04:46:55] Failed to ADL_Adapter_ID_Get. Error -1
      [2013-12-14 04:46:55] ADL found less devices than opencl!
      [2013-12-14 04:46:55] There is possibly more than one display attached to a GPU
      [2013-12-14 04:46:55] Use the gpu map feature to reliably map OpenCL to ADL
      [2013-12-14 04:46:55] WARNING: Number of OpenCL and ADL devices did not match!
      [2013-12-14 04:46:55] Hardware monitoring may NOT match up with devices!
      [2013-12-14 04:46:55] 1 GPU devices max detected

      Delete
    8. I also had the same issue as Kurt on Debian Jessie (I tried install drivers for R9 290 to my Debian Wheezy but it was not work even with kernel from backports).
      I solve it by purge all Driver and SDK and install ONLY driver amd-catalyst-13.11-betaV9.95-linux-x86.x86_64 (which is acctualy 13.25), it also contain SDK!
      After that mining works but system hanged after closing cgminer (via "q" or ctrl+c), a could see "divide error: 0000" in syslog. It is some bug in driver or cgminer but it alsa fixed in cgminer fork sgminer. It's almost the same, but with some features and bugfixes included - my choise.
      Thanks for post!

      Delete
    9. This comment has been removed by the author.

      Delete
    10. I also had the exact same problem as reported above with my R9 290's when starting cgminer:
      Error -1: Error -1: Getting Device IDs (num)
      clDevicesNum returned error, no GPUs usable

      I found out that this happens because the OpenCL library that comes with the AMD APP SDK does not support the R9 290. The version of AMD APP SDK that ships with the 13.8 driver however does support the R9 290. The issue is that if you install the APP SDK, your system will automatically be set to use the wrong OpenCL library because the APP SDK installer modifies your /etc/profile file.
      First, use the following command to check which OpenCL library you are using:

      ldd /usr/bin/clinfo

      If you get 'libOpenCL.so.1 => /opt/AMDAPP/lib/x68_64/libOpenCL.so.1' then you are using the wrong OpenCL version, supplied by APP SDK (it should be /usr/lib/fglrx/libOpenCL.so.1).

      The issue is that the APP SDK installer modified your /etc/profile file with the following lines:

      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/opt/AMDAPP/lib/x86_64":"/opt/AMDAPP/lib/x86"
      export LD_LIBRARY_PATH

      The fix is to comment out or delete those two lines above in your /etc/profile file. In addition, the installer places two files in your /etc/ld.so.conf.d directory: amdapp_x86.conf and amdapp_x86_64.conf. You need to delete both files.
      After deleting both of the above files and making the change to your /etc/profile file, run the following command:

      ldconfig

      and then restart. After restarting, run ldd /usr/bin/clinfo again and check to make sure that libOpenCL.so.1 now points to /usr/lib/fglrx/libOpenCL.so.1.
      Now, clinfo should show your cards and cgminer should no longer throw an error.

      You can see more info on this issue in the following thread:


      http://devgurus.amd.com/message/1301474#1301474

      Delete
    11. Also, if you run aticonfig and you get the following message:

      aticonfig: no supported adapters detected

      then you probably need to use a more recent fglrx driver. In order for my R9 290's to work, I needed to use the 13.11 driver. The 13.8 driver did not work for the R9 290's but it did work for my 7970's.

      When running cgminer -n, your OpenCL version should be:
      OpenCL 1.2 AMD-APP (1348.4)

      Delete
    12. I have to thank you, Patrick. You saved my day!

      Delete
    13. Thank you Patrick! Really helpful, even for a Linux newb.

      Delete
    14. Patrick! Very helpful, even for a Linux veteran. :)

      Delete
  5. Thank you for your nice post. I keep getting
    OpenCL...............: NOT FOUND. GPU mining support DISABLED
    It is a fresh 13.10 (Desktop) installation with 2xHD6990 cards. aticonfig --lsa sees the cards just fine.
    Catalyst-13.8-beta, ADL_SDK v6, AMD_APPSDK_v2.8
    Also tried Catalyst 13.11 and AMD_APPSDK_v2.9.
    Any help much appreciated.
    Thanks.

    ReplyDelete
    Replies
    1. Btw, I am using cgminer 3.7.2

      Delete
    2. Could you post the output of "lspci | grep VGA" and "cat /etc/X11/xorg.conf | grep BusID"?
      If you don't mind, could you post a pastebin of your /etc/X11/xorg.conf?
      Usually I've found that when cgminer can't find a GPU it's because of a problem with the X server configuration. I've had this problem so many times, but it's been something slightly different each time.i
      Are you running it from an SSH session or do you have a console up in a graphical environment?

      Delete
    3. Thanks for your quick reply.
      cat /etc/X11/xorg.conf | grep BusID
      BusID "PCI:13:0:0"
      BusID "PCI:12:0:0"
      BusID "PCI:5:0:0"
      BusID "PCI:4:0:0"

      /etc/X11/xorg.conf
      http://pastebin.com/ryRL80fg
      I was running a console in a graphical environment. (And now the Ubuntu top bar and sidebar are invisible....)
      In the meantime I wil retry with 13.04 headless.
      Thanks,
      Kjetil

      Delete
    4. I have the same problem...

      Delete
    5. Update:
      I tried again following instructions to the letter, thus 13.04 headless server + Catalyst-13.8-beta and AMD_APPSDK_v2.8.
      And now it works ;)
      Thanks! I'll donate when I've mined some coins.
      Cheers,
      Kjetil

      Delete
    6. Attn. Kjetil and Co.
      There is a file i.e. /cgminer/ADL_SDK/readme.txt which asks for copying 2 files from /AMD-ADL-SDK/cgminer/ADL_SDK. Please read it and do so!
      After doing this it compiles for me with Catalyst v13.12, AMD APP SDK v2.9 and ADL SDK 6.0.

      Delete
  6. Great write up dude, I will donate as soon as I have something

    ReplyDelete
    Replies
    1. thanks again for the excellent writeup, it's been very helpful, and as promised you should have .01 BTC awaiting in 1EBVjJSM7Qa1msYcU4AEFG3kLFimwXbAA9

      Delete
  7. for what it's worth, I have gotten this working in basically every iteration of Ubuntu 12.04, 12.10, 13.10, minimal and desktop. I have used the ADK 5 and 6, and all worked, as long as I installed 13.8. These steps are really solid, thanks to the comments section as well. The wget was clutch.

    If you have Desktop installed simply skip the xdm step, has worked for me several times, before I just went 100% headless.

    the hardware has been only 7990s and 7950s

    ReplyDelete
  8. would it still work if i do sudo update-rc.d xdm remove?

    ReplyDelete
    Replies
    1. If you have another way to run an X server, then maybe. But an X server has to be running and the user that runs cgminer needs to have access to it.

      Delete
  9. verything Installed & compiles well but I don't have /etc/X11/xorg.conf. What I missed? test.sh gives only:
    Setting of real/effective user Id to 0/0 failed
    Setting of real/effective user Id to 0/0 failed
    Xubuntu 13.10

    ReplyDelete
    Replies
    1. If you don't have a xorg.conf, try running "sudo aticonfig --initial --adapter=all" and see if it creates one, then reboot.

      Delete
  10. Now I have xorg.conf. But still: Setting of real/effective user Id to 0/0 failed

    spci | grep VGA
    01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cayman PRO [Radeon HD 6950]
    miner@miner-desktop:~/Downloads/cgminer$ cat /etc/X11/xorg.conf | grep BusID
    BusID "PCI:1:0:0"

    When booting I have XDM login. I go to first terminal (...F1) ./test.sh & only:
    Setting of real/effective user Id to 0/0 failed

    I have onboard GPUalso , but I think it does not do anything with this?

    ReplyDelete
    Replies
    1. I got cgminer working. I don't know why test.sh did not work? & I reinstalled with GUI the driver... Getting a lot off hardware errors?

      Delete
  11. Hello,

    I tried to beat it about a 3 days and always the same result. I was trying install 12.04.03 LTS, 13.04, 13.10, tried different catalysts 13.4, 13.8, 13.11. ADL 5.0, APP SDK 2.9. Also I tried different cgminers, from 2 till 3.7.2
    VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Pitcairn XT [Radeon HD 7870 GHz Edition] (prog-if 00 [VGA controller])

    leon@mine:~/cgminer$ ./cgminer -n
    No protocol specified
    [2013-12-17 07:25:32] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-12-17 07:25:32] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-12-17 07:25:32] CL Platform 0 version: OpenCL 1.2 AMD-APP (1348.4)
    [2013-12-17 07:25:32] Error -1: Getting Device IDs (num)
    [2013-12-17 07:25:32] clDevicesNum returned error, no GPUs usable
    [2013-12-17 07:25:32] 0 GPU devices max detected

    Thank you in advance,
    Leon.

    ReplyDelete
  12. FYI need to run cgminer as sudo. This tripped me up BIG TIME.

    ReplyDelete
    Replies
    1. Yea, I think something was messed up with my Lubuntu install. I nuked it and went for this headless version. Works w/o sudo now.

      Delete
  13. This probably has to be the best minimal miner setup :-) Thanks for posting!

    How do you autostart the cgminer with this setup on system boot?

    I can not seem to get it working from rc.local (with screen).

    ReplyDelete
    Replies
    1. I'm still trying to figure out how to start it at boot. I've gotten other things, like USB miners to start on boot, but I haven't gotten this one working yet.

      If I get it working, I'll add it to the guide. In the meantime, if you can get it working with rc.local and screen, let me know and I'll update the guide.

      Delete
    2. crontab -e:
      @reboot cd /home/miner/cgminer; sleep 120; screen -S cgminer -d -m ./runminer.sh

      Seems to work OK for me. I have another cronjob as sudo to make sure cgminer is running. If not, it restart xdm and runminer.sh as user miner. Not sure about this restarting thing yet.

      Delete
  14. Anyone else have 100% cpu usage while running cgminer? I don't know what the issue could be.

    ReplyDelete
    Replies
    1. According to the GPU-README Faq in cgminer it has to do with the version of the catalyst driver:

      ---cut---
      Q: The CPU usage is high.
      A: The ATI drivers after 11.6 have a bug that makes them consume 100% of one
      CPU core unnecessarily so downgrade to 11.6. Binding cgminer to one CPU core on
      windows can minimise it to 100% (instead of more than one core). Driver version
      11.11 on linux and 11.12 on windows appear to have fixed this issue. Note that
      later drivers may have an apparent return of high CPU usage.
      ---cut---

      Since AMD doesn't put a lot of effort in trying to keep their drivers compatible with different kernel versions I've been trying for days now to find a good combination. Also making legacy drivers work is THE HORROR. They sometimes don't even compile on a fresh install distro of that very time.


      Maybe we can put up a list together to see whats working?

      I'll start like this:

      Catalyst 13.11 beta V9.4 (=fglrx 13.25.5) + Kernel 3.8.0-27-generic on Ubuntu 13.04 64bit => cgminer 0,7%
      ?


      to find out what version of fglrx you're running type: dmesg | grep fglrx
      for kernel version: uname -a
      for cpu usage: top

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Catalyst 13.11 beta V9.4 (=fglrx 13.25.5) + Kernel 3.8.0-27-generic on Ubuntu 13.04 64bit => cgminer 0,7%
      Catalyst 12.11 beta (=fglrx 9.1.11) + Kernel 3.8.0-19-generic on Ubuntu 13.04 64bit => cgminer 27%
      Catalyst 13.12 (=fglrx 13.25.5?) + Kernel 3.8.0-19-generic on Ubuntu 13.04 64bit => cgminer 19%

      Delete
    4. I also encountered the 100% CPU usage problem recently:

      Catalyst 13.12, APP SDK 2.9 RC, kernel 3.8.0-35-generic, Ubuntu 13.04 64bit, sgminer 4.0.0 == 100% CPU usage

      Changing to Catalyst 13.8 beta did not help, but downgrading the APP SDK to 2.8 and recompiling sgminer seems to have fixed the problem, so:

      Catalyst 13.8 beta, APP SDK 2.8, kernel 3.8.0-35-generic, Ubuntu 13.04 64bit, sgminer 4.0.0 == <1%

      So, the problem might be in the APP SDK versions rather than the Catalyst versions.

      Delete
  15. hi,
    I follow the steps and install everything without any errors.

    [2013-12-29 02:37:18] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2013-12-29 02:37:18] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2013-12-29 02:37:18] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2013-12-29 02:37:18] Platform 0 devices: 1
    [2013-12-29 02:37:18] 0 Pitcairn
    [2013-12-29 02:37:18] GPU 0 AMD Radeon HD 7800 Series hardware monitoring enabled
    [2013-12-29 02:37:18] 1 GPU devices max detected

    But cgminer don't accept any shares. I see hashrate speed and average hashrate.
    Any ideas?
    Thank you in advance,
    Boyko

    ReplyDelete
    Replies
    1. A few things to check:
      *Are you getting any HW errors?
      *Did you start cgminer with --scrypt? (if you're mining Litecoins)

      Delete
    2. - no HW errors after 5 min of runing
      - I don't mine ltc at the moment. That is my current settings:
      "intensity" : "8",
      "worksize" : "256",
      "lookup-gap" : "2",
      "shaders" : "1024",
      "gpu-engine" : "900",
      "gpu-fan" : "45",
      "gpu-memclock" : "1200",
      "gpu-memdiff" : "0",
      "gpu-powertune" : "0",
      "gpu-vddc" : "0.000",
      "temp-cutoff" : "95",
      "temp-overheat" : "85",
      "temp-target" : "75",
      "log" : "5",
      "kernel-path" : "/usr/local/bin"
      }

      - This is result of ./cgminer -c cgminer.conf -D -T --verbose :

      [2013-12-29 03:46:55] Generated target 00000000000000000000000000000000000000000000000000fcff0300000000
      [2013-12-29 03:46:55] Generated stratum work
      [2013-12-29 03:46:55] Pushing work from pool 0 to hash queue
      [2013-12-29 03:46:55] Work stale due to block mismatch
      [2013-12-29 03:46:55] Popping work from get queue to get work
      [2013-12-29 03:46:55] Got work from get queue to get work for thread 1
      [2013-12-29 03:46:55] Generated stratum merkle 07c1f7f8ab522fd5be3f96a35c33155cae925bb9c6dc4aca80ba4408307720b2
      [2013-12-29 03:46:55] Generated stratum header 0000000109b3ba3e9fafdf5298cbc8400c522f7a15e37cd2fc42a04c72ef2753ccc8db1107c1f7f8ab522fd5be3f96a35c33155cae925bb9c6dc4aca80ba4408307720b252bf7f0e1c05266200000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000
      [2013-12-29 03:46:55] Work job_id 67d nonce2 04000000 ntime 52bf7f0e
      [2013-12-29 03:46:55] Generated target 00000000000000000000000000000000000000000000000000fcff0300000000
      [2013-12-29 03:46:55] Generated stratum work
      [2013-12-29 03:46:55] Pushing work from pool 0 to hash queue
      [2013-12-29 03:46:56] [thread 1: 134217728 hashes, 127249.0 khash/sec]
      [2013-12-29 03:46:56] [thread 0: 134217728 hashes, 126038.1 khash/sec]
      [2013-12-29 03:46:56] 53.0 C F: 45%(2281RPM) E: 900MHz M: 1200Mhz V: 1.138V A: 99% P: 0%
      [2013-12-29 03:46:57] [thread 1: 134217728 hashes, 130594.4 khash/sec]
      [2013-12-29 03:46:57] [thread 0: 125829120 hashes, 122320.8 khash/sec]
      [2013-12-29 03:46:58] [thread 1: 125829120 hashes, 124355.5 khash/sec]
      [2013-12-29 03:46:58] [thread 0: 134217728 hashes, 126346.3 khash/sec]
      [2013-12-29 03:46:58] 53.0 C F: 45%(2272RPM) E: 900MHz M: 1200Mhz V: 1.138V A: 99% P: 0%
      ^C [2013-12-29 03:46:59] Received kill message
      [2013-12-29 03:46:59] Killing off HotPlug thread
      [2013-12-29 03:46:59] Killing off watchpool thread
      [2013-12-29 03:46:59] Killing off watchdog thread
      [2013-12-29 03:46:59] Stopping mining threads
      [2013-12-29 03:46:59] [thread 1: 134217728 hashes, 126891.6 khash/sec]
      [2013-12-29 03:46:59] Thread 1 being disabled
      [2013-12-29 03:46:59] Popping wakeup ping in miner thread
      [2013-12-29 03:46:59] [thread 0: 142606336 hashes, 138299.8 khash/sec]
      [2013-12-29 03:46:59] Thread 0 being disabled
      [2013-12-29 03:46:59] Popping wakeup ping in miner thread
      [2013-12-29 03:47:00] Killing off mining threads
      [2013-12-29 03:47:00] Killing off stage thread
      [2013-12-29 03:47:00] Killing off API thread
      [2013-12-29 03:47:00] Releasing all USB devices

      Delete
  16. I noticed that the commands:
    sudo apt-get install xdm xorg
    Was needed before I installed the AMD drivers. Got loads of errors about X server before..

    ReplyDelete
  17. Hi guys!

    Could anybody kindly supply with amd-catalyst-13.8-beta2-linux-x86.x86_64.zip?

    It is impossible to download it from the web.

    I'd like to try it out to resolve 100% CPU consumation by cgminer

    my email 6406640 at gmail.com

    Thank you

    ReplyDelete
    Replies
    1. wget --referer="http://www.amd.com" http://www2.ati.com/drivers/beta/amd-catalyst-13.8-beta2-linux-x86.x86_64.zip

      still works

      Delete
    2. It is!

      Thank you!

      Delete
  18. I cannot get OpenCL to run headlessly here. That is, running it through an ssh session. If the machine starts up with xdm, I log in, then I can run OpenCL with the GPUs. If the machine starts up, and then I simply connect through an ssh session, the only device I can use OpenCL with is the processor. I'm running 2 5850's with a 6-core processor, for what it's worth. The output of clinfo on the logged in session (through xdm) shows both GPUs plus the CPU. The output of clinfo on the ssh session only shows the CPU. What am I doing wrong?

    ReplyDelete
    Replies
    1. Well, here are a few things I'd check: are you sure the $DISPLAY environment variable is set? If you log in through SSH and run "echo $DISPLAY", do you get ":0" or a blank line? If it's blank, try "export DISPLAY=:0" first and then "echo $DISPLAY" again to make sure it's set, then try to run an OpenCL application again. Also, it wouldn't hurt to double check if DisplayManager*authorize is set to false in xdm's config: "cat /etc/X11/xdm/xdm-config | grep authorize".

      Delete
  19. Nevermind, the "export DISPLAY=:0" was what I was missing. Is there a way to configure OpenCL to use the DISPLAY of the ssh terminal? I do x-forwarding on ssh sessions as needed, so it would be nice to have graphical output show up on my ssh session rather than the computer monitor connected to my GPU-box.

    ReplyDelete
    Replies
    1. Hmm... I'm not sure exactly what you're trying to do, but if I understand correctly, trying to forward an X application on a terminal that has $DISPLAY set will cause the application to show up on the remote display rather than being forwarded. I usually put the "export DISPLAY=:0" line in a script that also starts sgminer, so when I run that script, the scope of the $DISPLAY variable is limited to just that script/process; so when I run "echo $DISPLAY" on my SSH session, it's still unset, and X apps won't try to start on the remote display (just tested it with xterm on my mining server and it worked).

      Delete
    2. Hmmm, I see, I will try it. That's kind of a pain to execute every OpenCL program from within a script just to keep the DISPLAY variable limited to that process. On the OpenCL forums, someone wrote a guide to run OpenCL headless, without X server. I haven't tried it yet: http://devgurus.amd.com/thread/168273

      Delete
    3. Quick report: I tried http://devgurus.amd.com/thread/168273 (without installing xdm/xorg - 14.10+2.9+sg+adl6). It seems to work (as in sgminer starts hashing), but:
      - aticonfig (fglrx module issues) and sgminer (OpenCl device issues) throw errors
      - ADL doesn't work (no temps)

      I didn't dick around further. The gain is minimal, if any. It's just a few MBs more for xorg/xdm - the current proposed install is very clean in comparison.

      Delete
  20. Hey there,

    thanks from me too for the detailed guide. Sadly I'm stuck with the same problem that cgminer can't find a gpu on boot. I have an 7850 like you do, so it's not an hardware issue.

    Since I installed xdm next to lightdm cgminer now doesn't even find a gpu when starting on command line. This was working before.
    It has been puzzling me all day, I guess xdm installed a newer version of xorg-server which is incompatible with the latest ati drivers.

    I'll setup the system again from scratch as I've been trying to fix it all day, but I'm still not sure if cgminer will start on boot, as I first set up the system in a way similar to yours. Anyway, all help or ideas will be appreciated.

    CU, Robert.


    ReplyDelete
  21. Hello great guide, thank you very much! I am now running cgminer on a headless ubuntu server. I have one issue though. I start cgminer and after a while everything is soooooo slow. I mean cpu usage is at 0-1% but everything is lagging like hell. I type letters in the ssh connection and they appear with delays between them. If i try to open files to edit them it takes minutes. Its kinda weird. I am using the ATI driver suggested here, SDK 2.9, ADL 6.

    ReplyDelete
  22. Great post, I appreciate you and I would like to read your next post.Thanks for creating this informative post.

    Windows Thin Client & Citrix Thin Client

    ReplyDelete
  23. Disable Authorization on xdm
    (if you know of a better way to do this, please tell me...)


    sudo -s
    #enter password
    sed -i 's/DisplayManager\*authorize:.*true/DisplayManager\*authorize: false/' /etc/X11/xdm/xdm-config

    ReplyDelete
  24. Great information, I really like all your post. I will keep visiting this blog very often. It’s good to visit your website. And also please Read link bvba Woodstone which provide information server monitoring software & Network monitoring tools

    ReplyDelete
  25. Excellent blog ,,,, its helps you to remove your rundll problem click this site How To Remove Rundll Error Free from error.
    Thank you
    Aalia lyon

    ReplyDelete
  26. Krossover Networks provides a flexible and enthusiastic approach to its customer base. We take on our role as a key business partner with confidence. Our client base, from single PC sites to a multiple site organization, takes us into businesses in manufacturing, professional services, care, hospitality and tourism.
    http://krossovernet.com/

    ReplyDelete