bitcoin python OpenCL mining setup on Ubuntu 11.04

Credits: Thanks to Syke's article on!!!

0. Install Ubuntu/Drivers/APPSDK/pyopencl

  • Install Ubuntu 11.04 (desktop edition is recommended) on your disk, and install the 3rd party AMD/ATI graphic driver through "System->Administration->Additional Drivers".
  • $ sudo apt-get install python-pyopencl subversion git
  • Download AMD APP SDK for your platform (either 32bits or 64bits), and extracted to somewhere (referred as $SDK_HOME), remove the symbol link /usr/lib/ (links to nvidia implementation), and cp the *.so files in $SDK_HOME/lib/x86 to /usr/lib; extract the $SDK_HOME/icd-registration.tgz archive, and copy the *.icd files to /etc/OpenCL/vendors.
  • if you have multiple GPU, run $ aticonfig --adapter=all --initial, and relogin, then run $SDK_HOME/bin/x86/clinfo, to check if you have all GPU recognized.

1. Install python-jsonrpc

  • $ svn checkout
  • $ cd python-jsonrpc/
  • $ sudo python install

2. Retrieve and run poclbm mining scripts

  • $ git clone
  • $ cd poclbm
  • $ python -d 0 --user un --pass pw

3. aticonfig over ssh (the easiest way)

  • $ sudo apt-get install openssh-server
  • set autologin when you install/configure ubuntu gdm display manager
  • export DISPLAY=:0.0 after you connected to remote miner machine via ssh/telnet

4. Useful aticonfig commands

  • $ aticonfig --od-enable (enable overdrive)
  • $ aticonfig --odgc --adapter=all (get clocking information for all adapters)
  • $ aticonfig --odgt --adapter=all (get temperature for all adapters)
  • $ aticonfig --adapter=0 --pplib-cmd 'get fanspeed 0' (get speed of fan #0 on adapter #0)
  • $ aticonfig --odsc=950,1225 --adapter=1 (change the peak clock of adapter #1 to 950MHz)

5. Over-clocking with AMDOverdriveCtrl

  • Download and install the deb package here, and install depended wxgtk packages
  • $ AMDOverdriveCtrl -h (check which graphic card is active, and remember the index)
  • $ AMDOverdirveCtrl -i <card index> (you need to run it in native X11 environment), tune the parameters, and save it as default.
  • move the $HOME/.AMDOverdirveCtrl/default.ovdr to different location, then configure another card
  • add AMDOverdirveCtrl -b -i <card index> <profile_file> in your miner start script, note the profile_file must be in the current working directory.

Note: If you run the miner on multiple GPUs with overclocking, the master branch of poclbm seems not very stable as I experienced, the GPU stops to process anymore after running for a while, that I need a hard reset on my machine. Phoenix (though with poclbm kernel) seems much more stable, and comes up with better performance.

Tips of SunStudio debugger -- dbx

1. turn on gdb command emulator in dbx

(dbx) gdb on 

2. list the loaded shared objects, pre-load a shared object in dbx (not available in gdb mode)

(dbx) loadobject -list
(dbx) loadobject -load <the path to your shared object file>

3. list/stop in a static function within a shared object

(dbx) stop in ``your_static_function
(dbx) help scope

4. create the initial dbxrc file

(dbx) help .dbxrc > ~/.dbxrc
(dbx) help .dbxrc | sed 's/^##/  /' >$HOME/.dbxrc

2 Tips of C++ Programming with const

1. Implicit type conversion and copy constructor

If you want to define your own copy constructor, you should define like that:

class Foo {
  Foo (const Foo& obj) {}

Pay attention to the const in the parameter declaration. If your copy constructor definition loses const (Sun's C++ compiler does NOT complain), your implicit type conversion member will fail to compile, though the copy constructor is not used in type conversion.

class Foo {
  Foo (Foo& obj) {}
  Foo (Bar *obj) {}

Foo test () { return new Bar(); }

On linux with g++, you will get the error messages as following:
  error: no matching function for call to ‘Foo::Foo(Foo)’
  ... ...
  error:   initializing temporary from result of ‘Foo::Foo(Bar*)’

On solaris with sun studio c++ compiler, you will get:
  Error: Cannot use Bar* to initialize Foo without "Foo::Foo(const Foo&)"

2. The reference of pointer and "this"

Look at this piece of code:

void test (Foo* &obj) {}
//void test (Foo* const &obj) {}

class Foo {
  void bar () { test (this); }

On linux with g++, you will get error messages as following:
  invalid initialization of non-const reference of type ‘Foo*&’ from a temporary of type ‘Foo* const’
  in passing argument 1 of ‘void test(Foo*&)’

On solaris with sun studio c++ compiler, you will get:
  Error: Formal argument obj of type Foo*& in call to test(Foo*&) requires an lvalue.

Seems that sun studio c++ compiler treats the & in "&obj" as the addressing operator, so it requires an lvalue (left value). If we uncomment the 2nd test () (which in blue), then in function bar (), we must call test ((Foo *const) this); or just comment out the 1st test (), so that we could pass the compiling.

For non const members or external functions, the type of 'this' is Foo *const, for const members, its type is const Foo *const.