Updated 6/19/2011 - updated bitcoin app version to 0.3.23, simplified bitcoin setup directions
Updated 6/8/2011 - updated example app versions, clarified use of pools, clarified use of bitcoin standalone app, path cleanup, added link to headless mining guide
1. Introduction
Recently, I got interested in the new peer-to-peer digital currency, Bitcoin (read about it all about it at bitcoin.org if you're not familiar with it yet). Having decided to make use of my idling ATI graphics card for some bitcoin mining, I was able to cobble together a mining setup on Ubuntu 11.04 "Natty Narwhal" without too much trouble. It uses a standard miner app "poclbm", the Python OpenCL Bitminer.
Note that I already had a working official, ATI 'fglrx' graphics card driver package installed, so you'll want that taken care of before starting. I am also running the 32-bit version of Ubuntu; if you are on 64-bit, you can follow the 64-bit specific directions here (tested on 64-bit systems).
2. Install Ubuntu packages
Install required packages:
sudo aptitude install python-setuptools python-numpy \ subversion g++ libboost-all-dev
3. Install Bitcoin
Get the latest Bitcoin distribution, (0.3.23 as of this writing), unpack it to ~/bitcoin-0.3.23/, and set permissions.
cd ~ wget http://downloads.sourceforge.net/project/bitcoin/Bitcoin/bitcoin-0.3.23/bitcoin-0.3.23-linux.tar.gz tar xzvf bitcoin-0.3.23-linux.tar.gz chmod +x bitcoin-0.3.23/bin/*/bitcoin*
Configuring bitcoin:
cd ~ mkdir -p .bitcoin
Make up user/password here if you like:
echo "rpcuser=user" >> .bitcoin/bitcoin.conf echo "rpcpassword=password" >> .bitcoin/bitcoin.conf
Now we can run bitcoin in server mode,
~/bitcoin-0.3.23/bin/32/bitcoin -server &
And wait...and wait...hours...until the current block chain is downloaded and verified by your bitcoin client to catch up with the rest of the network. In the meantime, you can continue installing the rest of the software required for mining.
4. Install python-jsonrpc library
Install python-jsonrpc from official Subversion repository:
cd ~ svn checkout http://svn.json-rpc.org/trunk/python-jsonrpc cd python-jsonrpc/ sudo python setup.py install
5. Install AMD APP SDK
Grab the AMD APP SDK from the AMD website and install it:
64-bit:
cd ~ wget http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.4-lnx64.tgz tar xvzf AMD-APP-SDK-v2.4-lnx64.tgz echo export AMDAPPSDKROOT=${HOME}/AMD-APP-SDK-v2.4-lnx64/ >> ~/.bashrc echo export AMDAPPSDKSAMPLESROOT=${HOME}/AMD-APP-SDK-v2.4-lnx64/ >> ~/.bashrc echo 'export LD_LIBRARY_PATH=${AMDAPPSDKROOT}lib/x86_64:${LD_LIBRARY_PATH}' >> ~/.bashrc source ~/.bashrc cd / sudo tar xfz $AMDAPPSDKROOT/icd-registration.tgz
32-bit:
cd ~ wget http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.4-lnx32.tgz cd ~ tar xzvf AMD-APP-SDK-v2.4-lnx32.tgz cd AMD-APP-SDK-v2.4-lnx32/ echo export AMDAPPSDKROOT=${HOME}/AMD-APP-SDK-v2.4-lnx32/ >> ~/.bashrc echo export AMDAPPSDKSAMPLESROOT=${HOME}/AMD-APP-SDK-v2.4-lnx32/ >> ~/.bashrc echo 'export LD_LIBRARY_PATH=${AMDAPPSDKROOT}/lib/x86:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc cd / sudo tar xfz $AMDAPPSDKROOT/icd-registration.tgz
6. Install pyopencl
Now you have to install pyopencl from source because the Ubuntu package depends on the Nvidia driver package, which will mess up our system if we are on ATI.
cd ~ wget http://pypi.python.org/packages/source/p/pyopencl/pyopencl-0.92.tar.gz#md5=0680f7272fe3ab5a3bcb0b6cfbd74994 tar xzvf pyopencl-0.92.tar.gz cd pyopencl-0.92
32-bit configure:
./configure.py --cl-inc-dir=${AMDAPPSDKROOT}include --cl-lib-dir=${AMDAPPSDKROOT}lib/x86
64-bit configure:
./configure.py --cl-inc-dir=${AMDAPPSDKROOT}include --cl-lib-dir=${AMDAPPSDKROOT}lib/x86_64
Now build pyopencl:
make sudo make install
7. Install poclbm command line miner
Get poclbm modules:
cd ~ mkdir poclbm cd poclbm wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/BitcoinMiner.cl wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/BitcoinMiner.py wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/poclbm.py wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/sha256.py cd ~
8a. Solo mining
When the block chain is downloaded fully, you can start up poclbm for solo mining:
python poclbm/poclbm.py -d 0 --user user --pass passwordAnd wait a bit until you see khash/second appear.
8b. Pooled mining
To get more granularity from your mining results (i.e. the ability to make smaller earnings sooner, in exchange for a 0-3% fee), you can sign up for pooled mining at one of many pools, such as btcguild, btcmine, BitcoinPool, bitcoins.lc, or eligius. I recommend choosing one of the smaller pools in order to maintain health of the network, rather than favoring the largest pool by default. Search Google for "50% bitcoin hashpower problem" for more information on why this is important.
After you create an account at a pool, you'll generally need to create a separate worker for each miner that you run.
My poclbm command to mine in a pool looks like this:
python poclbm/poclbm.py -d 0 --host=[pool hostname] --port=8332 --user=[worker] --pass='[worker password]'
9. Final notes and related resources
After I wrote this, I found another complete guide for Ubuntu 11.04, targeted at 64-bit users, including the ATI fglrx driver installation if you haven't done that yet. You can find it on the bitcoin.org forums.
A guide for headless mining on Ubuntu 11.04 64-bit also exists on the bitcoin.org forums.
Debian users may also be interested in LinuxCoin, a ready-to-go Bitcoin client/mining distro based on Debian Squeeze.
Any problems following the directions, or comments, let me know. Happy mining!
Hi, I did all the things in the guide, when I want to mine I get this message :
ReplyDeleteerfan@erfan-desktop:~/Programs$ python poclbm.py -d 0 --user erfan --pass electr1cm0nk00
*** CAL version mismatch:
This OpenCL build requires version 1.4.879, version 1.4.635 installed.
Aborting.
can you tell me what does it mean, what is CAL version and how to fix it ? please !
Thanks for a grate post. There were a few bug in this for me so i posted on my blod with a few updates. My link is http://www.the-server-admin.com.
ReplyDeleteI told everyone to drop you some coin. So plese post a address so we can hook you up.
Erfan, what version of the AMD App SDK did you install? It sounds like a mismatch, maybe you need a newer version installed.
ReplyDeleteMarc: I'm glad the post was useful and thanks for linking back to me, I'll check to see what you had to do differently in your installation.
Per your request I have created a Bitcoin address 1AS6Zq1JEUtfWhmnNwkLumeCSErVzfnfzD if you'd like to donate. Thanks!
I used the wget command you had for SDK
ReplyDeletewget http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.4-lnx64.tgz
tar xvzf AMD-APP-SDK-v2.4-lnx64.tgz
The main changes was the install command I had to used sudo apt-get install. Also I got the new version of bitcoin and I have to change the connect command.
The 4 poclbm files need to be downloaded to a *separate* directory, not into the pyopencl directory as the instructions seem to indicate.
ReplyDeleteIf you see 'ImportError: No module named _cl' you have above problem.
Reinout,
ReplyDeleteThanks for the comment, I've corrected that section of the directions to use a separate directory/
I compleated your guide, but I ran into a problem. After trying to run poclbm i get this.
ReplyDeleteTraceback (most recent call last):
File "poclbm/poclbm.py", line 3, in
from BitcoinMiner import *
File "/home/box1/poclbm/BitcoinMiner.py", line 4, in
from log import *
ImportError: No module named log
Any ideas what I might have done wrong. I am pretty new to linux so this is all a little overwhelming.
That's odd:
ReplyDeleteTraceback (most recent call last):
File "poclbm.py", line 3, in
from BitcoinMiner import *
File "/home/todor/poclbm/BitcoinMiner.py", line 4, in
from log import *
ImportError: No module named log
Maybe somethings has changed lately.
svn doesn't seem to be working for me but
ReplyDeletehttp://json-rpc.org/wiki/python-json-rpc
describes how to use bazaar to do a checkout of the python-jsonrpc
I put this here because it came up early in my search for a solution
in case it's lost from there the exact line is
$ bzr checkout http://bzr.json-rpc.org/trunk/python-jsonrpc
I also got the error
ReplyDeleteTraceback (most recent call last):
File "poclbm/poclbm.py", line 3, in
from BitcoinMiner import *
File "/home/spleenux/poclbm/BitcoinMiner.py", line 4, in
from log import *
Yep i also get:
ReplyDeleteTraceback (most recent call last):
File "poclbm.py", line 3, in
from BitcoinMiner import *
File "/home/ashley/BitcoinMiner.py", line 4, in
from log import *
ImportError: No module named log
Hi, im getting an error when I try to make the pyopnecl:
ReplyDeletebpl-subset/bpl_subset/boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
make: *** [all] Error 1
Can you help me out I can figure whats wrong
Yeah getting the same error, and all the docs on bitcoin.org are gone..
ReplyDeleteTraceback (most recent call last):
File "poclbm/poclbm.py", line 3, in
from BitcoinMiner import *
File "/home/devious/poclbm/BitcoinMiner.py", line 4, in
from log import *
ImportError: No module named log
Any help would be greatly appriciated.
For those of you running into the import log and import util problems here's how you get past them. Instead of following the poclbm instructions above, only do these steps:
ReplyDeleteapt-get install git-core
cd
git clone git://github.com/m0mchil/poclbm.git
Now you can run it fine:
cd poclbm
./poclbm.py
Actually the latest python-jsonrpc correct command should be:
ReplyDelete"git clone https://github.com/trepca/python-jsonrpc.git"
instead of:
"svn checkout http://svn.json-rpc.org/trunk/python-jsonrpc"
The patchlevel.h header error is due to not having python-dev installed. Additionally, if running Ubuntu, the following packages are required:
ReplyDeletepython-setuptools python-numpy subversion g++ libboost-all-dev python-dev git-core
git-core is required for the updated git version of poclbm (suggested).
For everyone having trouble with the missing modules log util Transport etc. It is because you need all files accompanied by poclbm.py. Go to
ReplyDeletehttps://github.com/m0mchil/poclbm
and see the list of files. Then download them one by one
wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/log.py
wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/Transport.py
etc.
Then to connect to bitcoin, use the command:
python poclbm.py -d 0 https://user:pass@127.0.0.1:8334
where user and pass and 8334 are specified in your bitcoin.conf file
rpcuser=user
rpcpassword=pass
rpcport=8334
git clone git://github.com/m0mchil/poclbm.git
Deletedoes the thing.
File "./poclbm.py", line 80, in
ReplyDeleteimport BFLMiner
File "/home/pkarc/poclbm/poclbm/BFLMiner.py", line 4, in
from ioutil import find_udev, find_serial_by_id, find_com_ports
File "/home/pkarc/poclbm/poclbm/ioutil.py", line 2, in
from serial.tools import list_ports
ImportError: No module named tools
Hello everyone, I'm sorry for not being able to update this post recently. I haven't been mining but I'd still like to update the original post for Ubuntu 12.04 at some point. Thank you all commenters who clarified/corrected the changes since last year.
ReplyDelete