3 min read

How to Generate a Custom Bitcoin Address with an AMD GPU on Ubuntu

Have you ever wanted a bitcoin address that was more personalized and recognizable than the standard ~34 random character address?

Have you ever wanted a bitcoin address that was more personalized and recognizable than the standard ~34 random character address? It turns out that there’s a tool for that!

Vanitygen is an open source command-line custom bitcoin address generator that allows you to create addresses containing a specific string of characters. You can read all about it on this Bitcointalk thread.

Note: there’s a great guide for getting Vanitygen working on Linux with Nvidia GPUs here.

Displaying a custom address with a human readable prefix can add a bit of credibility to your payment or donation requests, as it shows that you expended computational resources to create the address. I only recommend doing this for public donation addresses that you don’t mind (or explicitly want) the entire world tracking. This is because the recommended practice for bitcoin is to never re-use an address, but rather to generate a new address for every payment. Address re-use makes it easier for others to identify which transactions belong to you on the blockchain.

Generating vanity addresses on Linux is fairly simple. Note that vanitygen’s “-i” parameter indicates case insensitivity with the character matching; searching for the exact case will be much more computationally difficult and take a lot longer to find a perfect match. The last parameter is the prefix of the bitcoin address for which vanitygen will search. FYI, the longer the prefix for which you are searching, the exponentially more difficult it becomes to find a match. Also, remember that single signature bitcoin addresses all begin with a “1" character. Here are the specific commands:

jameson@lopp:~/$ sudo apt-get install git
jameson@lopp:~/$ git clone http://github.com/samr7/vanitygen.git
jameson@lopp:~/$ cd vanitygen
jameson@lopp:~/vanitygen$ make
jameson@lopp:~/vanitygen$ ./vanitygen -i 1statoshi
Difficulty: 46698974966440
[555.09 Kkey/s][total 3517553344][Prob 0.0%][50% in 1.8y]

1.8 years to 50% probability of finding a match? So… potentially 3.6 years to definitely find a match? I don’t have that long! Surely we can do better. Thankfully, GPUs are much faster at performing this type of calculation than CPUs, and user “nonnakip” figured out how to get the GPU-enabled version of vanitygen working on Ubuntu with an AMD graphics card. Nonnakip notes that this method was tested with AMD Radeon 7XXX series cards; I tested it with a 6XXX series and found it worked as well. According to reports I’ve seen online, Vanitygen will also work on AMD Radeon 5xxx series but you need to use AMD SDK 2.7 or earlier. Here are the steps:

jameson@lopp:~/$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) restricted"
jameson@lopp:~/$ sudo apt-get update
jameson@lopp:~/$ sudo apt-get install build-essential git libssl-dev libpcre3-dev opencl-headers fglrx-dev
jameson@lopp:~/$ sudo reboot

After rebooting you can build oclvanitygen:

jameson@lopp:~/$ git clone http://github.com/samr7/vanitygen.git
jameson@lopp:~/$ cd vanitygen
jameson@lopp:~/vanitygen$ wget https://nastyfans.org/download/patch-oclvanitygen-amd.diff
jameson@lopp:~/vanitygen$ patch -p1 < patch-oclvanitygen-amd.diff
jameson@lopp:~/vanitygen$ wget https://nastyfans.org/download/AMD-APP-SDK-v2.7-lib-lnx64.tar.gz
jameson@lopp:~/vanitygen$ mkdir sdklib
jameson@lopp:~/vanitygen$ tar -xzvf AMD-APP-SDK-v2.7-lib-lnx64.tar.gz -C sdklib
jameson@lopp:~/vanitygen$ make oclvanitygen
jameson@lopp:~/vanitygen$ env LD_LIBRARY_PATH=./sdklib ./oclvanitygen -D 0:0 -i 1statoshi
Difficulty: 46698974966440
Compiling kernel, can take minutes...done!
[21.17 Mkey/s][total 173808287744][Prob 0.4%][50% in 17.6d]

Great! So we went from checking 555,090 keys per second to a whopping 21,170,000 keys per second. That’s a 38X speedup and the time difference is considerable — a month of computational work with a CPU now only takes a day with a GPU. Higher end video cards will have even greater speedups.

There’s a lot more that you can learn about the vanitygen tool from the Bitcointalk thread linked at the top, including how to import the generated private keys into wallet software. Good luck!