Generating a Bitcoin Vanity Address with Azure N-Series GPU Virtual Machines

Generating a Bitcoin Vanity Address with Azure N-Series GPU Virtual Machines

Tom Chantler
 • 10 min read

Summary

The purpose of this article is to demonstrate the raw computing power of Microsoft's new Azure N-Series GPU Virtual Machines. To achieve this we're going to generate a Bitcoin vanity address but, of course, you can do any computational task which can be accelerated by using a GPU.

The Azure N-Series VMs use NVIDIA Tesla K80 and M60 GPUs and support OpenGL, DirectX, OpenCL and CUDA. Other Azure services such as Machine Learning, Hadoop, etc, will make use of these GPUs and there will be various N-Series images in the Azure Marketplace in due course.

I have included full instructions to get up and running using either Windows Server 2012 R2, Windows Server 2016 Technical Preview 5 or Ubuntu 16.04 LTS.

Background

The other day I thought it might be fun to generate my own Bitcoin vanity address. You know, something like 1TomSSL.....

To understand what's going on, all you need to know is that a Bitcoin address is a 160-bit hash of the public portion of a public/private ECDSA keypair and therefore it's not completely straightforward to make a personalised Bitcoin address; it's probably going to involve a brute-force search.

Whilst there are people offering to do this as a service, I decided that it would be more fun (and potentially less risky) to do it myself.

From what I could gather, the best way to do this yourself is to use Vanitygen which uses a probabilistic search and basically tries millions[1] of keys until it finds one that fits your pattern (in my case, the case-sensitive string 1TomSSL, since all Bitcoin addresses start with 1).

You can learn a lot more (perhaps more than you desire) about Bitcoin addresses here. There's a link to a less technical article there too.

Doing it myself using my old laptop

I've mentioned my old laptop before, but I didn't give you any of the specs (other than a vague allusion to it being quite powerful but not really lappable).

My old laptop has an Intel i7-2860QM processor and an NVIDIA GTX 580M GPU (which has 384 CUDA cores).

When it runs vanitygen, it can generate around a million keys per second just using the CPU (via the command vanitygen64.exe) and around 11.50MKey/s using the GPU (via the command oclvanitygen.exe). This is actually pretty good.

A note about timings

When I quote an amount of time, that is for 50% probability of finding the address. The actual key generation may proceed more quickly (or indeed more slowly) than that.

PatternDifficultySpeed50% Time
1TomC264,104,2241.0 MKey/s3 minutes
1TomC264,104,22411.50 MKey/s20 secs
1TomSSL888,446,610,5381.0 MKey/s7 days
1TomSSL888,446,610,53811.50 MKey/s15 hours
1TomSSLx51,529,903,411,2451.0 MKey/s~ 1 year
1TomSSLx51,529,903,411,24511.50 MKey/s~36 days
1TomSSLxx2,988,734,397,852,2201.0 MKey/s~65 years
1TomSSLxx2,988,734,397,852,22011.50 MKey/s~6 years
1TomSSLdotCom33,822,000,858,357,061,464,9831.0 MKey/s~740 million years
1TomSSLdotCom33,822,000,858,357,061,464,98311.50 MKey/s~65 million years

Looking at this, I should be able to generate 1TomSSL myself overnight (if I go to bed early and get up late; it'll take about 15 hours). I'll need to use the GPU though, as it will take about a week if I just use the CPU.

My old laptop dies

I tried to generate a Bitcoin address starting 1TomSSL a few times on my laptop and, each time it got to about 42%[2], it died by crashing. On a couple of other occasions I tried doing something else whilst vanitygen was running and it really died, as in just stopped as if the power had been cut off.

How much will it cost to get someone else to do it?

I found one place online that would generate vanity Bitcoin addresses for me. Short addresses are free. Here are the prices for the case-sensitive addresses we're interested in:

1TomSSL will cost me just under $14 (about £10.75 at the time of writing).
1TomSSLx will cost me just over $800 (~£616).
1TomSSLxx will cost me just under $47,000 (~£36,200).

Can I do it myself for less money? Almost certainly, although it might take ages.

Azure to the rescue

Azure N-Series VMs use NVIDIA Tesla K80 and M60 GPUs and support OpenGL, DirectX, OpenCL and CUDA. They are not yet generally available; for access you have to sign up to the preview at http://gpu.azure.com/.

You can see the prices here: Linux and Windows.

They range from around £0.34 to £1.55 an hour for CentOS/Ubuntu to £0.40 to £1.83 for Windows.

So what do you get for your money? Quite a lot, as it turns out.

NC6NC12NC24
Cores6 (E5-2690v3)12 (E5-2690v3)24 (E5-2690v3)
GPU1 x K80 GPU (1/2 Physical Card)2 x K80 GPU (1 Physical Card)4 x K80 GPU (2 Physical Cards)
Memory56 GB112 GB224 GB
Disk380 GB SSD680 GB SSD1.44 TB SSD
NV6NV12NV24
Cores6 (E5-2690v3)12 (E5-2690v3)24 (E5-2690v3)
GPU1 x M60 GPU (1/2 Physical Card)2 x M60 GPU (1 Physical Card)4 x M60 GPU (2 Physical Cards)
Memory56 GB112 GB224 GB
Disk380 GB SSD680 GB SSD1.44 TB SSD

Info in table taken from https://azure.microsoft.com/en-gb/blog/azure-n-series-preview-availability/

This looks like you get the same server hardware and just add a different GPU using Discrete Device Assignment (DDA). You can read more about that here. It's very clever.

So how do I actually get access?

Since I'm not a big company, I feared that I would probably not be very near the top of the list when it came to being granted preview access to the N-Series VMs.

However, one evening last week I tweeted asking if anybody could help me out. I'm not sure why; I didn't really expect to get any response.

Within two hours I had received a response from Karan Batta (as luck would have it, he's the person in charge of Azure GPU computing) asking me to send him a Direct Message. 48 hours later, I had access. Wow! Isn't social media marvellous? Here are the tweets.

Okay, cool, I've got access. Now what?

Windows Server 2016 Technical Preview 5

I went to https://portal.azure.com/ and created a new VM via Virtual Machines → + Add → Windows Server → Windows Server 2016 Technical Preview 5.

During the preview, you need to make sure you choose VM disk type of HDD and the South Central US Region.

Create NC6 VM Part 1

Then, when choosing the size, View all and choose NC6 Standard, like this:

NC6 Standard VM Selection

Since this is just a test, I kept all the default values it created for a new storage account, virtual network, etc. I didn't create an availability set and I disabled monitoring. So I pretty much skipped step 3 (other than to disable monitoring).

Then I saved the template for future use and clicked OK to deploy the VM. After a few seconds, everything had been created and the VM was deploying. A couple of minutes later, it was ready.

I know this is not unique to Microsoft Azure, but the idea that I can provision a server on-demand like this still amazes me.

I navigated to the VM in the Azure Portal and clicked Connect and it downloaded an RDP profile which I double-clicked and which then prompted me for my login credentials.

Once I'd logged in, I checked the device manager and saw this:

NC6 Device Manager Before

When I tried to download the driver (remember this is Windows Server 2016), I got this error:

Admin can't run Edge browser error

So I launched PowerShell and did this:
PS > iwr -outf ./driver.exe "https://azuregpu.blob.core.windows.net/nc-drivers/Win10_x64(369.09)-1011017-01.exe"

Get Driver using PowerShell

NOTE: This driver is not the one that was linked in the original invitation email. If you're using Windows Server 2016 Technical Preview 5 you need this driver instead.

After I installed the drivers, the Device Manager looked like this, so I knew it had worked:

NC6 Device Manager After

How fast is it?

On the NC6, oclvanitygen 1TomSSL ran at about 38MKey/s and it reckoned it would take about 4½hrs for 1TomSSL at a cost of about £1.80. That's less than £10.75, but there was some effort involved. You decide if it was worth it (I think it was).

oclvanitygen Windows Server 2016

Windows Server 2012 R2

This was almost the same as Windows Server 2016 Technical Preview 5 and yielded approximately the same results. However, you need to use a different driver. Download it using PowerShell with this command (note that it's a .zip file, not a .exe).

PS > iwr -outf ./driver.zip https://azuregpu.blob.core.windows.net/nc-drivers/362.81_win8_win7_64bit_international-1009160-02.zip

oclvanitygen Windows Server 2012 R2

What about Ubuntu?

I found it somewhat irksome to get vanitygen up and running on Ubuntu, although it looks easy now I've written it down. Here's how I did it (using SmarTTY based on Scott Hanselman's recommendation):

First I set up the VM using the Azure Portal in much the same way as I did for Windows Server 2016, but I chose Ubuntu 16.04 LTS. Then, once I'd logged in (obviously I couldn't use an RDP profile; instead I noted down the IP address and entered that into SmarTTY), I did this:

$ sudo apt-get update
$ wget "https://azuregpu.blob.core.windows.net/nc-drivers/NVIDIA-Linux-x86_64-361.69-1009163-01.run"
$ chmod +x NVIDIA-Linux-x86_64-361.69-1009163-01.run
$ sudo apt-get install gcc make
$ sudo ./NVIDIA-Linux-x86_64-361.69-1009163-01.run

I ignored a couple of warnings about the X library path and being unable to install a 32-bit version of the drivers.

Then I needed to install vanitygen, so I did this:

$ sudo apt-get install libssl-dev libpcre3-dev opencl-headers
$ git clone https://github.com/samr7/vanitygen
$ cd vanitygen
$ make
$ make oclvanitygen

Then I ran oclvanitygen like this:

oclvanitygen on Ubuntu

As you can see, it ran at about the same speed as it did on Windows, although perhaps slightly faster (bearing in mind the fact that the speed fluctuated on all three platforms).

When not using the GPU, Ubuntu ran considerably faster than Windows. Around 2.35 MKey/s compared to 1.56 MKey/s for Windows.

What about multiple GPUs?

In Windows, you will see something like this in Device Manager after you've successfully installed the drivers:

Multiple GPUs in Device Manager

If you have more than one GPU, when you run oclvanitygen you will be prompted to select your OpenCL device(s), like this (from Windows Server 2016 TP5):

Vanitygen Choose OpenCL Device

You need to specify each OpenCL device using the -D n:n switch, so to use all four GPUs, the command becomes

oclvanitygen -D 0:0 -D 0:1 -D 0:2 -D 0:3 1TomSSL

The syntax is exactly the same for Windows and Linux.

Similar speed on Ubuntu and Windows

Both Windows Server 2016 Technical Preview 5 and Ubuntu 16.04 LTS generated keys at the rate of around 130 MKey/s when running on the NC24 VM (with four NVIDIA Tesla K80 GPUs).

Vanitygen Complete on Ubuntu 16.04 LTS

It took around an hour and forty minutes to complete (remember it's a probabilistic search; it doesn't always end at the 50% mark and I was slightly unlucky) at a cost of around £2.30. As expected, it's slightly more expensive to use more GPUs (as the speed doesn't quite scale linearly), but remember that part of the reason we're doing this is convenience and speed; I'm paying so that I don't need to tie up my machine for seven days.

Further work

There may be other applications (or forks of vanitygen) that can generate vanity Bitcoin addresses more efficiently. I didn't look into this.

It might be interesting to look at the NV-series machines, which feature the M60 GPU. They shouldn't be quite as fast as the K80 GPUs for this kind of application.

It might also be interesting to look at some other uses for the N-Series machines and I will probably do that in a future article.

Conclusion

In this article we have seen how easy it is to use the new Azure N-Series Virtual Machines to run your GPU tasks. We chose the rather contrived example of generating a vanity Bitcoin address, but I hope that you can see how you might be able to apply this to other computationally intensive tasks.

Remember that, despite the impressive results, it's still early days for these new Azure virtual machines. Expect performance upgrades (with the next being due in a couple of weeks - I'll update this article when that happens) before General Availability which will happen before the end of the year.

This is exciting technology and I'm very interested to see what people do with it.

Finally, I'd like to thank Karan Batta again for sorting out my access to the N-Series machines.

If you found this article useful, you can comment below, subscribe or follow me on Twitter.



  1. More like billions, or even trillions. For 1TomSSL over 700 billion keys were tried. I feel I should probably plant a tree or something to offset this. ↩︎

  2. It's a computer and it was in deep thought, so at what percentage would you expect it to die? ↩︎