Foreverrising Blog

April 9, 2011

BitCoin Mining in Ubuntu with an NVIDIA card

Filed under: Software — Tags: , , , , , , , , , , — foreverrising @ 5:39 pm

Installing and using BitCoin miners is not difficult, but I posted this to gather everything in one main page.

Update: I wrote and posted Mining with an ATI Radeon Card in Ubuntu last night. This article is for mining in Ubuntu with Nvidia cards.

Note: The main BitCoin client needs to be installed. It can be downloaded from BitCoin.org or installed from the command line in Ubuntu with the following commands:

sudo apt-add-repository ppa:stretch/bitcoin

sudo apt-get install bitcoin

Also note, I got this working with a pretty low-grade card: a Galaxy Nvidia GT 220. It’s installed on a Dell Studio XPS 5700, AMD II x4. My PC is currently using Ubuntu 10.10 64-bit with all updates.

This post is based on my short experience with BitCoin, but I hope to build upon it- I will be installing a better graphics card in a couple of days (ATI Radeon 5770).

I came across an article about BitCoin mining while trying to find information to install a certain wifi adapted in Ubuntu 10.10 64-bit. The article Free graphics card by earning bitcoins by gurrier, sounded interesting. This article is a good starting point if you have a ATI card and would like to mine.

However I did not have a ATI card, but I went ahead and installed the BitCoin client, and grabbed free Bitcoins from the BitCoin Faucet. From there I sought out instructions for using the card I currently have. The instructions that I used:

sudo apt-get install python-pyopencl subversion
wget http://iweb.dl.sourceforge.net/project/bitcoin/Bitcoin/bitcoin-0.3.19/bitcoin-0.3.19-linux.tar.gz
tar xvf bitcoin-0.3.19-linux.tar.gz
svn checkout http://svn.json-rpc.org/trunk/python-jsonrpc 
cd python-jsonrpc/
sudo python setup.py install
cd ..
mkdir .bitcoin
echo "rpcuser=un" > .bitcoin/bitcoin.conf
echo "rpcpassword=pw" >> .bitcoin/bitcoin.conf
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
~/bitcoin-0.3.19/bin/64/bitcoin -server&
python poclbm.py -d 0 --user un --pass pw

Make sure you start the bitcoin server with:

bitcoind -server

The problems I ran into were difficult for me to grasp. The first was easy, file not found. Just search for the appropriate script and place it in the same directory as poclbm. The other problems I’ve run into all include the flags to use on the command line.

-v is for ATI cards, so this will not work correctly with an Nvidia card. When using this switch in ignorance, by hashrate dropped signifigantly.

askrate should be 2^32 / [your hashrate].

You can also use Bitcoinpool’s modified miner with this, however I recommend monitoring that status since it throw an error after awhile.

I accept donations @ 1HXrbVT3WRqk6rHTPKKJ9ppoFbsYjmjTqX if this worked for you. If it didn’t, feel free to send me a comment.

14 Comments »

  1. Nice Writeup! I got my GTS250 working working mostly off your instructions here. the only thing missing was that I had to download the sha256 file using the following:

    wget –no-check-certificate https://github.com/m0mchil/poclbm/raw/master/sha256.py

    Cheers!

    Comment by Peter Anselmo — May 18, 2011 @ 8:30 pm

  2. Hi,

    Thanks for the post. It all seems to be working now. I was wondering how i can see how many bitcoins have been generated and how to get them off the server and into my wallet? O should this be used with a Pooling site?

    Thanks in advance,
    Luke

    Comment by Luke — May 20, 2011 @ 5:41 am

    • There is no payout until a block is solved. Then length of time it takes for a single GPU to solve a block has grown so large that I do pooled mining. Blocks are solved in under a day, and once the block is confirmed through the bitcoin network, the payout is disbursed. In a pool, it would then be split up for payout.

      I run a Radeon 5770 and 6870. Even when overclocked to the limit, and mining 24/7, it could take over a month to solve a block on my own. Try a pool.

      Comment by foreverrising — May 20, 2011 @ 7:40 am

  3. Ever seen this?

    Exception in thread Thread-2:
    Traceback (most recent call last):
    File “/usr/lib/python2.6/threading.py”, line 532, in __bootstrap_inner
    self.run()
    File “/usr/lib/python2.6/threading.py”, line 484, in run
    self.__target(*self.__args, **self.__kwargs)
    File “/home/adesai/bitcoin/BitcoinMiner.py”, line 272, in miningThread
    self.loadKernel()
    File “/home/adesai/bitcoin/BitcoinMiner.py”, line 355, in loadKernel
    self.context = cl.Context([self.device], None, None)
    RuntimeError: Context failed: out of host memory

    Comment by Ninja — May 20, 2011 @ 6:53 pm

    • (pretty sure I have plenty of memory)

      Comment by Ninja — May 20, 2011 @ 6:54 pm

    • No, I have not. What happens when you run fglrxinfo in a terminal? 355:

      354 def loadKernel(self):
      355 self.context = cl.Context([self.device], None, None)
      356 if (self.device.extensions.find(‘cl_amd_media_ops’) != -1):
      357 self.defines += ‘ -DBITALIGN’
      358
      359 kernelFile = open(‘BitcoinMiner.cl’, ‘r’)
      360 kernel = kernelFile.read()
      361 kernelFile.close()
      362 m = md5(); m.update(”.join([self.device.platform.name, self.device.platform.version, self.device.name, self.defines, kernel]))
      363 cacheName = ‘%s.elf’ % m.hexdigest()
      364 binary = None
      365 try:
      366 binary = open(cacheName, ‘rb’)
      367 self.miner = cl.Program(self.context, [self.device], [binary.read()]).build(self.defines)
      368 except (IOError, cl.LogicError):
      369 self.miner = cl.Program(self.context, kernel).build(self.defines)

      Check your paths and the flags you are using.

      Comment by foreverrising — May 22, 2011 @ 9:39 pm

  4. I got this error first time:
    /bitcoin -server& python poclbm.py -d 0 –user un –pass pw
    [1] 6450
    Traceback (most recent call last):
    File “poclbm.py”, line 5, in
    from BitcoinMiner import *
    File “/home/chris/Downloads/bitcoin-0.3.21/bin/64/BitcoinMiner.py”, line 8, in
    from sha256 import *
    ImportError: No module named sha256

    it’s solved by running:
    wget –no-check-certificate https://github.com/m0mchil/poclbm/raw/master/sha256.py

    Otherwise than you very much, finally this stuff makes sense and is actually working

    Comment by psypher246 — May 26, 2011 @ 4:06 am

    • I got that error early on when I had started mining with an nVidia card. Thanks for the comment.

      Comment by foreverrising — May 27, 2011 @ 10:29 am

  5. Hi

    Did anyone have similar problem :

    24/08/2011 15:56:11, Setting server (wonglik @ localhost:8333)
    localhost:8333 24/08/2011 15:56:35, No more backup pools left. Using primary and starting over.
    localhost:8333 24/08/2011 15:56:35, Setting server (wonglik @ localhost:8333)
    localhost:8333 24/08/2011 15:56:59, No more backup pools left. Using primary and starting over.
    localhost:8333 24/08/2011 15:56:59, Setting server (wonglik @ localhost:8333)
    localhost:8333 Problems communicating with bitcoin RPC 2 2^C

    Comment by von.g — August 24, 2011 @ 8:03 am

    • Double check your command line options and bitcoin.conf on your server.

      Comment by foreverrising — August 25, 2011 @ 10:10 pm

  6. http://svn.json-rpc.org seems to be permanently down. Do you know about some another source of python-jsonrpc?
    If not, could you post somewhere that sources for download?

    Comment by ohm — September 2, 2011 @ 2:39 pm

  7. cd python-jsonrpc/
    sudo python setup.py install

    setup.py inside the trunk directory

    cd python-jsonrpc/trunk/
    sudo python setup.py install

    Comment by john — January 11, 2012 @ 8:55 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.