In my previous two posts in this series I introduced two easy-to-use bitcoin miners for OS X: BitMinter and GUIMiner. However, while these miners are relatively easy to install and use, they do not offer the best performance when it comes to hash rates. For that you’ll want to look at cgminer and bfgminer. These are native C miners and, paired with the right kernels, their performance exceeds the other two miners by quite a wide margin.
cgminer & bfgminer
The bfgminer project is a fork of the cgminer project. Now, I have no dog in this fight, but my understanding is that the teams aren’t on great terms. However, I have had good luck with both tools and have worked with both authors in order to fix a crash (cgminer, bfgminer) related to multiple GPU’s on OS X and have no complaints whatsoever. Both miners offer similar performance in my experience.
To get started, you will need to install the Xcode. Xcode is a free download from the Apple App Store.
2. Command Line Tools
Next you’ll need the Xcode Command Line Tools. Launch Xcode and then click the Xcode>Preferences menu item. Click the Downloads tab and then click Install next to Command Line Tools.
If the text next to Xcode Command Line Tools says Installed, carry on to the next step.
Next you’ll need to install Homebrew. Homebrew is a package manager for OS X that provides a sane way of installing *nix tools, libraries, and their dependencies. It is similar to MacPorts for OS X or apt for Linux. Installing Homebrew is super-easy. Open up Terminal.app and run the following command (from the Homebrew homepage):
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
After you install Homebrew, make sure you run the following command (as the installer should instruct you):
Make sure you address any errors or warnings before proceeding as they may prevent the miners from installing.
In my previous post I indicated that it was necessary to compile cgminer and bfgminer from their source code in order to install them on OS X. While that was necessary at the time, after some reading and experimenting with Homebrew I was able to create packages (called formulas with Homebrew) for installing cgminer and bfgminer on OS X 10.8. Once Homebrew is successfully installed, you can run the following commands to install cgminer and bfgminer:
brew tap nwoolls/xgminer
brew install cgminer
brew tap nwoolls/xgminer
brew install bfgminer
If you specify the –HEAD (two dashes) parameter for brew install then the latest source-code will be pulled for the miner from Github rather than using the latest official release.
You can visit the Github repository to view the package contents.
If you run into errors installing the above formulas you can try running brew install with the –debug –verbose parameters to find where things went wrong. I’d also recommend using brew doctor to diagnose any issues.
Both cgminer and bfgminer are command-line utilities. You can either run them without any command line parameters and fill in the prompts for mining pool URL and credentials or you can use the following format to specify your pool:
cgminer -o http://pool.url:port -u username -p password
bfgminer -o http://pool.url:port -u password -p password
If you have multiple graphics cards you’ll want to use the –no-opencl-binaries parameter with bfgminer to avoid a crash on startup. This is not necessary with cgminer as it detects OS X and applies the same workaround automatically.
Other notable command line parameters are -I (for intensity) and -k (for kernel). If you pass in -I d then the miner will use less resources so you can use your PC (think D for Desktop). Passing in -I 9 is a safe value for having the miner use as much of your graphics resources as possible to mine. Your PC will be much less responsive. Finally, -k lets you specify a kernel. I find on OS X that using -k diablo gives the best performance. So, my command-line using cgminer with the BitMinter pool would look something like this:
cgminer -k diablo -o http://mint.bitminter.com:8332 -u username_workername -p password -I 9
And for bfgminer:
bfgminer -k diablo -o http://mint.bitminter.com:8332 -u username_workername -p password -I 9 --no-opencl-binaries
Refer to the projects on Github for full documentation of the available command-line parameters.
As you can see from the average in the upper-left of each miner’s output, with cgminer and bfgminer I average 460 Mh/s. Compare that to 400 Mh/s with GUIMiner and 370 Mh/s with BitMinter and you can see why these command-line miners are preferred over their GUI counterparts.
These are exciting times for crypto currency, whether you’re a geek or a speculator or merely a bystander. And, while OS X is pulling up the rear when it comes to supported OS’s for bitcoin mining, hopefully I’ve demonstrated some viable options for getting your feet wet with mining on OS X. BitMinter is a great option for getting started, as it gives you both a bitcoin mining pool with low fees and ready-to-use mining software. GUIMiner is a nice option for improved performance and flexibility in mining pool choice. And, if you’ve decided mining is your thing and you want the absolute best performance out of your rig, you can’t go wrong with cgminer or bfgminer.
UPDATE #1: Since my original post I’ve had some great help from Bitcoin community member and blogger Kerry on how to get binaries such as cgminer and bfgminer packaged in a self-contained way. If you are interested in the shell scripts that make this possible you can check them out on Github here. I have submitted these scripts to the authors of both cgminer and bfgminer so, in the future, we may see official OS X binary distributions.
In the meantime, if you’d like to try these out instead of following the instructions above, you can download them from the Releases page here.
UPDATE #2: Starting with version 3.8 cgminer no longer includes any support for GPU mining, so you will need to use version 3.7.2 of cgminer if you intend to mine using your GPU. Additionally, bfgminer now requires an additional argument in order to enable GPU mining. If you wish to use bfgminer for GPU mining you will need to add the following argument: