A Mining and Machine Learning PC for $500

In my never-ending quest for the “next big thing” in technology, I’ve been dividing my time between cryptocurrency and machine learning. I’m still not sure about the long-term value of Bitcoin and other altcoins, but the tech they’re built on, such as blockchain and smart contracts, is fascinating.

At the same time, it seems like machine learning is set to take over the world. I’ve been working my way through a couple of online data science / machine learning / deep learning courses. I’m particularly interested in learning more about TensorFlow, Google’s machine learning library.

In order to speed up processing with TensorFlow, I decided to build a PC with a decent graphics card. When I’m not using this PC to run machine learning programs, I could use the video card to mine a few altcoins. Finally, worst case scenario, if both of these technologies fail I’ll have a decent computer for gaming.

The Hardware

My first step was finding a video card. TensorFlow uses the CUDA Toolkit from NVIDIA so that seemed like a good place to start. I also knew that to mine Ethereum, I needed at least 4GB of memory on the card. With that in mind, I ended up choosing the EVGA GeForce GTX 1050ti Video Card for $157.99. Not exactly top-of-the-line, but good enough to get started on a budget.

Now I needed a PC to hold this card. Again, I was trying to go cheap so I looked into refurbished computers. There’s an off-lease, refurbished computer store near my house. I was able to pick up a Dell computer there with a keyboard, mouse, and monitor for about $350.

I went with the Dell Optiplex 7010. The 3.2 GHz i5 processor is plenty fast for my needs, and the mini-tower case provides plenty of room for the video card. I also bought a TP-Link N150 USB Wireless Adapter since this computer didn’t have built-in wireless.

The Software

The computer came with Windows 10 (which is actually not terrible), but I knew I wanted to run Linux for my purposes. So, I shrank the primary partition on the hard drive and downloaded a copy of Ubuntu Desktop 16.04.3 LTS and created a bootable USB flash drive.

There are already plenty of resources online explaining how to set up a dual-boot Windows / Ubuntu system so I won’t cover that here. Let me know if you run into trouble and I’ll try to point you in the right direction.

Once Ubuntu is installed, make sure the video card is using the proprietary drivers. The open-source drivers won’t cut it for mining or machine learning. To check, go to System Settings, then Software & Updates, and click the Additional Drivers tab. After the tab loads, you should see that your video card is using the NVIDIA binary driver. If not, select it and click the Apply Changes button.

Ethereum Mining

Now that the operating systems are installed, I was ready to start setting up the rest of the software. I decided to test mining first. You can’t mine Bitcoin on a regular computer, so it was out of the question, but you can mine Ethereum.

With that in mind, first install Ethereum. This is easy to do on Ubuntu using the Ethereum PPA (Personal Package Archive). These instructions are from the Go Ethereum Wiki. First, open a terminal and enter these commands:

This adds the Ethereum PPA to your system, updates the list of available packages, and installs the Ethereum software. Once that’s complete, enter the following command to create a new Ethereum account:

geth account new

Be sure to write down your password and keep it in a safe place. This account holds all of your ether. Without the password you won’t be able to access your money. Also, make a note of your address. That’s the number returned by the command between curly braces.

Now it’s time to install the miner. There are several choices for mining on the Ethereum network. After trying a few different options, I chose Claymore.

First, download the Claymore Dual Miner v10.0 from their releases page on GitHub. Make a new directory named claymore for the miner inside your home directory. Now move the downloaded file from your Downloads directory to the claymore directory and extract it by double clicking it.

Rather than try to mine solo, I decided to join a mining pool. Again, there are many choices available, but after some research I went with nanopool.org. Their 1% fee seemed reasonable, and you can get payouts after mining as little as 0.05 ether.

The nanopool.org getting started guide includes instructions for setting up Claymore on Linux. After correcting a few typos everything worked perfectly. First, I replaced the contents of the file start.bash with this:

The number starting with 0xa375... is my Ethereum address. You should replace this with your own, unless you want me to get all the ether you mine. Following that is my worker name and then my email address. nanopool.org will use this to email you if your worker goes. It’s also used as a password to update settings.

The format is similar to start.bash but slightly different. These servers will be used if the server you entered in start.bash goes down.

Now that these files are updated, you can open a terminal and start the miner by entering this command:

~/claymore/start.bash

The command will first build a DAG on your video card which takes a few seconds, then it will start getting jobs from nanopool.org and attempting to mine ether. Occasionally, you will see text in green on your terminal that says “SHARE FOUND” and then “Share accepted”. This means your mining worked and you just earned a little ether.

You can see my results by looking at my worker on nanopool.org. At around 12 Mh/second I’m certainly not going to get rich off of this miner, but $10-15 USD per month is better than nothing. It’s not often that I actually get paid to learn about a new technology.

Machine Learning with TensorFlow

Now that Ethereum mining is working, I moved on to installing TensorFlow. The TensorFlow website has great documentation for Installing TensorFlow on Ubuntu, but there a few gotcha’s in the documentation.

Install NVIDIA Requirements

The first requirement for using TensorFlow with a GPU is the CUDA Toolkit from NVIDIA. The current required version is 8.0, but the latest version on NVIDIA’s site is 9.0. TensorFlow currently will not work with the latest version.

Once I had the versions worked out, CUDA is easy to install. The first step is to add the CUDA repository to your system. Rather than doing it manually as with Ethereum, CUDA provides a .deb package to do this for you.

The next requirement is the CUDA Deep Neural Network library. This download requires a membership in the NVIDA Developer Program. Thankfully, it’s free. Go to the cuDNN Download page, and signup or login as required.

Click to expand the section labeled “Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0”. In that section are three .deb files to download for Ubuntu 16.04:

cuDNN v6.0 Runtime Library for Ubuntu16.04

cuDNN v6.0 Developer Library for Ubuntu16.04

cuDNN v6.0 Code Samples and User Guide for Ubuntu16.04

After downloading those three files, open a terminal, go to the Downloads directory, and enter these commands: