OpenCL HOWTO FOR FEDORA 12 LINUX
Here are some notes which may be useful to anyone who wishes to mine for bitcoins on Fedora 12 Linux. It took me about ten hours to get all of this working, because many of the standard Fedora packages are different to what bitcoin needs and generate all kinds of odd errors when you try to build the makefile.
If you aren't already running Fedora, save yourself a lot of time and hassles by installing Ubuntu instead.
Check your software versions, and upgrade as necessary. The gcc compiler needs to be 4.x (for PyOpenCL), and Python needs to be 2.4 or newer (again, for PyOpenCL).
$ gcc --version
gcc (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)
$ python --version
You need to have either the full kernel source, or the kernel headers (because the ATI GPU driver is installed by compiling a kernel module.
$ rpm -q kernel-devel
$ rpm -q kernel-PAE-devel
Update your display driver.
I followed the instructions from here:http://gofedora.com/how-to-install-ati-catalyst-fglrx-98-drivers-fedora-11/
except that I used the version 10.10 of the ATI Catalyst Display Driver for Linux x86 from here:http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx?type=2.4.1&product=220.127.116.11.42&lang=English
Apparently some of the installation steps are no longer needed with version 10.10, but I wasn't completely certain which ones, so I did them all anyway.
Get the ATI Stream SDK v2.1 (NOT any later version, according to brocktice), from here: http://developer.amd.com/gpu/ATIStreamSDK/pages/ATIStreamSDK-Archive.aspx
You need two downloads from that page: the Linux SDK (32-bit or 64-bit according to your version of Linux), plus icd-registration.tgz
Untar the SDK anywhere convenient. Add these lines to your .bash_profile file (in your login directory):
export ATISTREAMSDKSAMPLESROOT=...<some path>.../ati-stream-sdk-v2.1-lnx32
export ATISTREAMSDKROOT=...<some path>.../ati-stream-sdk-v2.1-lnx32
Move icd-registration.tgz into your root directory and (as root) untar it from there. It puts some config files into /etc.
Follow the documentation that is included in the SDK to compile the examples. Execute ati-stream-sdk-v2.1-lnx32/samples/opencl/bin/x86/CLInfo to check that things are working and that your GPU card is detected.
Install the Python OpenCL module (PyOpenCL). Broadly, follow the instructions here:http://wiki.tiker.net/PyOpenCL/Installation/Linux
However, in step 2 I couldn't install the Numpy dependency this way. Instead I ran "System | Administration | Add/Remove Software", then searched for numpy and installed it.
In step 3, the OpenCL headers and libraries weren't found, so I had to use the longer configure.py example and provide explicit paths.
The "Boost C++" libraries are not required for this version of PyOpenCL, but we will need them later (see below).
Install the JSON-RPC module for Python. This was straightforward using the instructions here:http://json-rpc.org/wiki/python-json-rpc
Go to m0mchil's Git repository:https://github.com/m0mchil/poclbm
Click the "Download" button. Download and unpack these files anywhere convenient. Change poclbm.py to executable and check that it's working:
chmod 744 poclbm.py
Next we need to get bitcoin's dependencies correct.
Install wxWidgets version 2.9.0 (not 2.8 or 2.9.1). You can get version 2.9.0 from here:http://biolpc22.york.ac.uk/pub/2.9.0/
Follow the instructions in file build-unix.txt from the /src directory of the bitcoin distribution, except that you will need to be root ("su -") for the whole install, not just the "make install" step.
The version of OpenSSL that ships with Fedora excludes the elliptic curve cryptography due to patent concerns. Assuming you're in a country without absurd software patent laws, download the source for the latest 0.9.8 version (currently 0.9.8p) of OpenSSL from here:http://www.openssl.org/source/
Build, test and install it according to the instructions in the download. However, the standard installation doesn't install the static libraries, so I made some symbolic links:
sudo ln -s `pwd`/libssl.a /usr/lib
sudo ln -s `pwd`/libcrypto.a /usr/lib
You need the static
version of the Boost C++ development libraries installed. I installed this from package boost-static-1.39.0
You need the static
version of the Berkeley DB development libraries installed. I installed this from package db4-devel-static-4.7.25
This installed a file libdb_cxx-4.7.a in /usr/lib, but the makefile wanted libdb_cxx.a, so I created a symbolic link:
sudo ln -s libdb_cxx-4.7.a libdb_cxx.a
Go to the GIT repository for m0mchil's bitcoin-getwork patch:https://github.com/m0mchil/bitcoin-getwork
Notice which SVN revision number the patch is for, and use that
number instead of 181 in the following command (which downloads the development version of bitcoin):
svn co -r 181 https://bitcoin.svn.sourceforge.net/svnroot/bitcoin
Change into the newly-created directory that holds the sources:
From m0mchil's repository, click "Download" and download the archive. Extract the file getwork-latest.patch into the bitcoin/trunk directory.
Modify the sources by applying the patch:
patch -p0 -i getwork-latest.patch
It should tell you that it has updated files main.cpp, main.h and rpc.cpp.
We need to tweak Bitcoin's makefile, which is the file bitcoin/trunk/build-unix.txt
In the WXLIBS section of the makefile, add the line
and also add a trailing backslash to the previous line (it's a line-continuation character). A comment in the makefile says you only need to do this if you have wxWidgets 2.9.1, but I had to do it for 2.9.0.
If your version of "Boost" is less than 1.40 (I'm using 1.39), edit bitcoin's makefile (src/build-unix.txt) and add -mt to the end of the name of each of the "Boost" libraries. There are four of these, in the four lines after the line that contains the string "-Bstatic".
Built the getwork-modified version of bitcoin:
make -f makefile.unix
This should build a binary called 'bitcoin' in this directory. Try it out! If you already have another instance of bitcoin running, close it. Type ./bitcoin to check that your newly-compiled instance works. If it works OK, close it and we'll move on to mining.
If you don't already have a file bitcoin.conf in your ~/.bitcoin directory, create one and put a username and password in it:
Go back to the bitcoin/trunk directory and start bitcoin in rpc server mode:
./bitcoin -server &
Go to the directory where you built poclbm.py and run it:
./poclbm.py --user=yourusername --pass=yourpassword
It will ask you which device to use. Choose the one that's not
Watch the khash/s figures with sweet delight, and enjoy the few moments before the roar of your cpu fan starts up.
Many thanks to m0mchil and the many others who have offered code or helpful tips.