Bitcoin ATI GPU mining
Following on from my supercomputer post I've decided to write a little guide for you guys on how to get bitcoin mining using your GPGPU's via backtrack. This will benefit people that have backtrack installed to there HDD.Ok first we need to get our system/s setup and the GPU's running. If you have already installed the relevant drivers etc you can skip these sections.
First how to ATI.
If your using SSH to access your machine/s follow this first
You probably don't want to run a full windows manager that's using resources but you need x running to use ATI cards so I would just install gdm.
Code:
apt-get update apt-get install gdm
Next edit /etc/gdm/gdm.conf and addNext edit /etc/gdm/Init/Default and add the following code just before the exit 0.
xhost + chmod uog+rw /dev/dri/card*
Your now ready to ssh into your machine and begin.Ok lets move on your going to need to grab some package.
AMD APP SDK v2.4 32 bit
or
AMD APP SDK v2.4 64 bit
and
ATI Catalyst 11.3
Here's a patch that fixes the fglrx module to compile with kernels 2.6.37+
--- ./firegl_public.c +++ ./firegl_public.c @@ -114, 7 +114, 7 @@ #include #include #include -#include +#include // newer SuSE kernels need this #include @@ -848, 8 +848, 8 @@ static int fglrx_pci_suspend(struct pci_ * happen much less frequent then without this workaround. */ if (state == PM_EVENT_SUSPEND) - acquire_console_sem; - + console_lock; + if (firegl_cail_powerdown(privdev, state)) ret = -EIO; @@ -870, 7 +870, 7 @@ static int fglrx_pci_suspend(struct pci_ } if (state == PM_EVENT_SUSPEND) - release_console_sem; + console_unlock; KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, ret, NULL); @@ -894, 7 +894, 7 @@ static int fglrx_pci_resume(struct pci_d if (PMSG_EVENT(pdev->dev.power.power_state) == 0) return 0; if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND) - acquire_console_sem; + console_lock; #ifdef FIREGL_USWC_SUPPORT // Restore the PAT after resuming from S3 or S4. @@ -919, 7 +919, 7 @@ static int fglrx_pci_resume(struct pci_d firegl_cail_powerup(privdev); if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND) - release_console_sem; + console_unlock; PMSG_EVENT(pdev->dev.power.power_state) = 0; KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, 0, NULL); @@ -1894, 13 +1894, 13 @@ void ATI_API_CALL KCL_spin_unlock(void * /** \brief Grab global kernel lock */ void ATI_API_CALL KCL_GlobalKernelLock(void) { - lock_kernel; + /* lock_kernel; removed */ } /** \brief Release global kernel lock */ void ATI_API_CALL KCL_GlobalKernelUnlock(void) { - unlock_kernel; + /* unlock_kernel; removed */ } /*****************************************************************************/ --- ./kcl_ioctl.c 2011-04-22 15:81777 +0100 +++ ./kcl_ioctl.c 2011-04-22 15:81778 +0100 @@ -193, 7 +193, 7 @@ void ATI_API_CALL KCL_IOCTL_UnregisterCo */ void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size) { - void __user *ret = COMPAT_ALLOC_USER_SPACE(size); + void __user *ret = arch_compat_alloc_user_space(size); /* prevent stack overflow */ if (!access_ok(VERIFY_WRITE, ret, size))
Lets start with catalyst. I always install these while in single user mode. Sometimes I find that the install script cannot disable the old modules running and fails. So lets switch into single user mode.and CD into the directory where you have the binary stored and invoke itFollow the on screen instructions and install. Next check your fglrx log stored in /usr/share/ati/fglrx-install.log. If everything looks ok your ok to move on, if not copy and paste my patch into a txt file and save it as "ati_kernel_patch.patch". Copy the patch over to /lib/modules/fglrx/build_mod/ run the patch and recompile.patch -p1 < ati_kernel_patch.patch sh ./make.sh cd .. sh ./make_install.sh
If you have other issues post them here and I'l see if I can help you out. Hopefully you now have the ATI fglrx modules installed. Now lets get the cards running !!For a single card run...
aticonfig --initial
For multi cards run ...aticonfig --adapter=all --initial
Lets go back into multi user. This will also restart XNow lets check to see if crossfire is activeIf crossfire is still active you may have to do
aticonfig --adapter=all --cf=off
and restart X again.Congratulations you now have your ATI GPU's setup for bitcoin mining / pyrit etc. Now lets take this one step further and overclock our cards.
Lets enable overdrive on our card/s. If you only have one card you only need to run this on display 0.
DISPLAY=:0 aticonfig --enable-od DISPLAY=:0.1 aticonfig --enable-od .....
Ok now lets look at how far we can push things.DISPLAY=:*youcard aticonfig --odgc
And you should see something like the following ..Default Adapter - ATI Radeon HD 5800 Series Core (MHz) Memory (MHz) Current Clocks : 840 1140 Current Peak : 840 1140 Configurable Peak Range : [600-900] [900-1300] GPU load : 98%
The part we are interested in is Configurable Peak Range : [600-900] [900-1300]. That's the range that you can play with. There is no one set way to configure this you will just have to tinker.Here's how you set the clocks
DISPLAY=:*youcard aticonfig --odsc=core, memory DISPLAY=:*youcard aticonfig --odcc
Check the aticonfig manual for more info as explaining all this is way out of the scope of this tutorial. And we still haven't covered the SDK !!Now lets extract the SDK into an appropriate directory and build our sdk.
tar -C /opt -xvf AMD-APP-SDK-v2.4-lnx*.tgz cd /opt/AMD-APP-SDK-v2.4-lnx* LLIBS+="GL GLU" make tar -C / -xvf icd-registration.tgz
Ok now we need to setup our library paths etc. You could just export everything every time you login or add this to the end of /etc/bash.bashrcATISTREAMSDKROOT=/opt/AMD-APP-SDK-v2.4-lnx*youversion LD_LIBRARY_PATH+=/opt/AMD-APP-SDK-v2.4-lnx64/lib/x86_64 export ATISTREAMSDKROOT LD_LIBRARY_PATH
and there you have it you have your ATI GPGPU's ready to crunch code .For nvidia users. Purehate has wrote an excellent guide on how to get these cards up and running in backtrack. I don't see the need to rewrite this so I'm just going to link it
Give yourself a pat on the back you've come a long way lol. next is to setup pyopencl and get mining !!!
First lets setup a working directory and get everything.
mkdir /root/bitcoin cd /root/bitcoin apt-get install python-pyopencl wget clone xvf bitcoin-0.3.20.2-linux.tar.gz
Ok now we have everything we need to mine bitcoins If python-pyopencl starts downloading lots of nvidia stuff and you don't need it don't worry. So lets configure bitcoin to run as a daemon and get mining.mkdir /root/.bitcoin echo "rpcuser=yourusername" > /root/.bitcoin/bitcoin.conf echo "rpcpassword=yoursupersecretpassword" > /root/.bitcoin/bitcoin.conf echo "rpcallowip=127.0.0.1" > /root/.bitcoin/bitcoin.conf
Now when I want to run a mining cluster all I have to do is add the ip addresses of the nodes. I had troubles with wildcards so I add every node as a single line.echo "rpcallowip=10.42.43.52" > /root/.bitcoin/bitcoin.conf echo "rpcallowip=10.42.43.53" > /root/.bitcoin/bitcoin.conf and so on ...
Now your ready to start up your bitcoin daemon./root/bitcoin/bitcoin-*/bin/64/bitcoind
Next lets get poclbm mining on your daemon./root/bitcoin/poclbm
Now I just wrote a little bash script to get everything fired up on this machine and set the fan speed on my ATI cards. Nvidia users I can't help you too much from now on as I haven't had no experience with these cards. But your most of the way now and google is your friend maybe someone else could add the nvidia stuff for setting up fan speeds etc.