LiteCoin Mining on EC2

UPDATE: The price for spot instances has risen and the value of LiteCoin has dropped. The combination of these two factors makes LiteCoin mining on EC2 likely to be unprofitable at the present time. I'm sure a lot of people will be paying close attention paid to the spot prices now though…

Original post:

LiteCoin mining on Amazon EC2 is currently profitable when using g2.2xlarge spot instances. Although the historical average spot price for g2.2xlarge instances has already nearly doubled (presumably because of miners bidding the price up), it will remain profitable at current LTC prices (~$41) until the spot price exceeds ~$0.20 per hour.

You can currently get roughly 185 khash/s from the g2.2xlarge instances if you use both the GPU and CPUs: ~150 khash/s from the GPU, and ~35 khash/s from CPU mining with six threads. If you use seven or eight threads, you starve the GPU mining and overall performance drops.

Note that EC2 limits you to 10 g2.2xlarge spot instances per region, so you'll need to run them in multiple regions to get more than 10 instances; however, even with only 10 instances, you should be able to mine ~1.2 LTC (~$50) per day at the current difficulty level.

To start mining, you'll need to create an account on a pool. is easy to get started with quickly and seems to work well enough. After creating an account, you'll want to setup two workers per EC2 instance — one for GPU mining and one for CPU mining. For the GPU worker, I would recommend setting the "Suggest Diff" at 16 and "Max Diff" at 128. For the CPU worker, set "Suggest Diff" at 8 and "Max Diff" at 64.

In the EC2 management console, you'll want to go to the Spot Requests page and click "Request Spot Instances". Select Amazon Linux AMI (HVM) 2013.09.1, and the GPU instance g2.2xlarge. On the following page, just change the number of instances to 10 and set your maximum price to something reasonable (i.e. less than $0.20 or it won't be profitable).

Once your spot instance requests have been filled and your instances have launched, login with SSH and set them up:

sudo yum -y groupinstall "Development Tools"
sudo yum -y install git libcurl-devel python-devel screen rsync yasm numpy openssl-devel
sudo sh

That last step is the CUDA installer, which will ask you a few questions — you'll want to accept everything and keep the default paths.

Next, setup the GPU miner, CudaMiner (note that the latest version is broken when compiling on this AMI as of December 3, hence the git reset to the previous revision):

git clone
cd CudaMiner
git reset –-hard 88c6da6d5c2b798d1de7031e8dbcc2678f635e4b
PATH=/usr/local/cuda-5.5/bin:$PATH make

Start a screen session and launch CudaMiner to start mining!

LD_LIBRARY_PATH=/usr/local/cuda-5.5/lib64 ./cudaminer -o stratum+tcp:// -u YOUR_ACCOUNT.YOUR_MINER -p YOUR_MINER_PASSWORD -C 1

(Detach from the screen by pressing Ctrl+A, then D.)

To install cpuminer:

cd ~
git clone
cd cpuminer/
./configure CFLAGS="-O3"

You'll need to setup the stratum mining proxy because cpuminer doesn't have stratum support built in, which is required to connect to the WeMineLTC pool. To setup the stratum mining proxy:

cd ~
git clone
cd stratum-mining-proxy/
sudo python
cd litecoin_scrypt/
sudo python install
cd ..
sudo python develop
chmod +x
./ -o -p 3333 &

Then start another screen session for your CPU miner:

cd ~/cpuminer/

(Detach your screen session again with Ctrl+A, then D.)

As an added bonus, you may still be able to get $100 of Amazon EC2 credit, which would give you a few free days of mining.

Good luck mining! If you're interested in learning more about Amazon Web Services, check out my upcoming book, AWS Architecture.

56 thoughts on “LiteCoin Mining on EC2

  1. Bob Feldbauer Post author

    The spot instance pricing is per instance. When it passes $0.20 per instance, it will most likely no longer be profitable to mine LiteCoin (unless of course the value of Bitcoin, and thus LiteCoin, rise).

  2. Luke

    When try to install the NVIDIA CUDA Toolkit it initially gives me a warning that I am attempting to install on an unsupported configuration, and the install eventually fails.
    I am guessing this is due to the wrong AMI? Mine is amzn-ami-hvm-2012.09.0.x86_64-ebs.

  3. Internet

    Strange, I don't see the g2.2xlarge instance as an option on any region. Is there another setting I'm missing?

  4. Hao

    Bob, the current lowest price for g2.2-xlarge is $0.25, "Your Spot request price of 0.2 is lower than the minimum required Spot request fulfillment price of 0.25.", i am not sure if it's still profitable to do the mining at this price

  5. Atanas Bozhkov

    The amazon spot-prices just sky-rocketed. Right now the price is sitting at $0.25 per instance, which even with the $100 voucher gives you about 40 hours of mining. If demand doesn't go down this scheme will be obsolete.

  6. lukas

    Arhg they limited they max to 5 now! 😀

    What is the best way to restart instances as soon as price ration is ok? Ideally with some sort of presistance for driver etc.

  7. Greg Ledet

    Bob, the math doesn't quite add up. Difficulty will jump to about 1800 tomorrow morning. At 1800 difficulty, 185 KH/s makes 0.09924172 LTC per day. At $35 per LTC, that’s $3.47 per day in revenue. You’d have to pay less than $0.145 per hour per instance to be profitable, at $0.145 you break even. Right now, everyone and their brother has maxed out the GPU instances on EC2.

    As we sit right now, 185 KH/s makes 0.11732177 LTC per day. At $35 per coin (it's $32 at the time of this reply), you'd have to pay less than $0.171 per hour for your instance.

  8. noname

    Great post! but to make it work I had to also execute the following command: sudo ldconfig /usr/local/cuda/lib64

  9. Denis


    Great tutorial. I could only get to instances launch though, as I now get a "Status Code: price-too-low Status Message: Your Spot request price of 0.2 is lower than the minimum required Spot request fulfillment price of 0.96" message.
    Care to shed some light ? It seems LTC price surged today, how can profitability be calculated ? Best regards.

  10. John

    Just tried to set up the 10 instances. Amazon told me that 20 cents was too little and it would cost at least 31.

  11. Bob Feldbauer Post author

    You're right – this was never going to be a profitable strategy long term, and changes in LTC value and spot prices have limited it even further. As far as the math goes, at the time I wrote this the spot price was at ~$0.10 and LTC was at $41-42. You would get 0.11732177 LTC per instance per day, times ten, so 1.17 LTC per day (~$47.97). That's why I said that when the spot price increased to $0.20 it would no longer be profitable (as it would then cost ~$48/day to run 10 instances).

  12. Bob Feldbauer Post author

    I was seeing ~145-155 kh/s on GPU and 35 kh/s CPU (using only 6 threads for CPU because otherwise the GPU can't get enough processor usage in). It sounds like you're using too many threads for CPU mining and losing on the GPU end.

  13. Bob Feldbauer Post author

    No, it just shows the economics of spot instance pricing. All coin mining is profitable by *some* method, or there would be no miners (and therefore, no coins). It just happens that for a brief time, the value of LTC had gone up enough where EC2 instances became profitable. As expected from free market theory, the spot instance price has now increased.

  14. gyurisc

    What does the YOUR_USERNAME.YOUR_MINER mean? I understand that I supposed to put the username in, but whereis the YOUR_MINER part coming from?

  15. noname

    The price for these spot instances running "Cluster Instances HVM SUSE Linux Enterprise 11" is lower (but of course the instructions to make it work will be different)

  16. DanyO

    Hey, your tutorial is for Linux based AWS instances. Do you know if it's possible to mine litecoins on Windows Base g2.2xlarge instances?

  17. Bob Feldbauer Post author

    It is possible to mine LiteCoin on Windows – I wouldn't see any reason you couldn't do it on EC2, but generally Windows instances on EC2 cost more because of the additional cost of Windows licensing.

  18. Bob Feldbauer Post author

    Very nice work Adam! I was going to automate the setup or generate an AMI, but thought the opportunity was probably going to be too short lived. There may be similar opportunities in the future if the value of LTC increases and spot prices for the GPU instances remain low enough though, so having an automated setup method certainly helps!

  19. Bob Feldbauer Post author

    YOUR_MINER is the name for the worker you created on the mining pool (WeMineLTC was the pool I used in my example). I basically just used numbers for the workers (1,2,3, etc), so in my case it was MY_USERNAME.1 for the first EC2 instance, MY_USERNAME.2 for the second EC2 instance, and so on.

  20. Buge

    Does it still work? (I know it's not profitable.) But when I do the make cudaminer step, it gives a bunch of errors like " error: identifier "__funnelshift_l" is undefined"
    Then when I try to run cudaminer, the executable doesn't exist.

    It's really strange because I had it working earlier right after you posted this, but now when I try with the exact same steps it doesn't work.

  21. Adam W

    I have then exact same test_kernel error Buge. It is strange cause everything worked fine for me too the other day. I'm not sure if it just with amazon linux hvm ami or all g2.2xlarge instance's, but there is definitely something that has changed preventing cudaminer from running.

  22. gavint

    CudaMiner no longer compiles using the instructions above after a git checkin by the developer on the 1st. If you do a git reset to the previous checkin it will works – replace the second block of commands with this:
    git clone
    cd CudaMiner
    git reset –hard 88c6da6d5c2b798d1de7031e8dbcc2678f635e4b
    PATH=/usr/local/cuda-5.5/bin:$PATH make

  23. iva

    I can't install cuda toolkit – i was using Amazon Linux AMI (HVM) 2013.09.1 – ami-5a20b86a and the installation fails and I get "the driver installation is unable to locate the kernel source". Can you help fix this?

  24. Kristian

    Thanks for writing this post, even if its not profitable anymore I'm testing it out for the sake of learning and using the free $100 coupon.

    I’ve been able to compile the miner and install all the drivers and have it running, but it results in 2 things both which don’t work.

    Without auto tune:
    [2013-12-05 06:47:09] 1 miner threads started, using 'scrypt' algorithm.
    [2013-12-05 06:47:09] Starting Stratum on stratum+tcp://
    [2013-12-05 06:47:09] Stratum detected new block
    [2013-12-05 06:47:12] GPU #0: GRID K520 with compute capability 3.0
    [2013-12-05 06:47:12] GPU #0: interactive: 0, tex-cache: 2D, single-alloc: 1
    [2013-12-05 06:47:12] GPU #0: using launch configuration K70x4
    [2013-12-05 06:47:12] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:13] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:15] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:15] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:16] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:16] GPU #0: GRID K520 result does not validate on CPU!
    [2013-12-05 06:47:17] GPU #0: GRID K520 result does not validate on CPU!

    And with auto tune:
    [2013-12-05 06:51:08] 1 miner threads started, using 'scrypt' algorithm.
    [2013-12-05 06:51:08] Starting Stratum on stratum+tcp://
    [2013-12-05 06:51:08] Binding thread 0 to cpu 0
    [2013-12-05 06:51:09] Stratum detected new block
    [2013-12-05 06:51:12] GPU #0: GRID K520 with compute capability 3.0
    [2013-12-05 06:51:12] GPU #0: interactive: 0, tex-cache: 0 , single-alloc: 0
    [2013-12-05 06:51:13] GPU #0: Performing auto-tuning (Patience…)
    [2013-12-05 06:51:13] GPU #0: maximum warps: 977
    [2013-12-05 06:51:13] GPU #0: 0.00 khash/s with configuration K0x0
    [2013-12-05 06:51:13] GPU #0: using launch configuration K0x0
    Floating point exception
    [ec2-user@ip-172-31-24-209 CudaMiner]$

    I’ve tried to manually specify launch configs in the K ranges but it still results in a does no validate error.

    Thank you very much for your time, and I hope someone is able to help me.

  25. Yair

    Thanks for the details.
    I need some help though – couldn't get nvidia to install:

    The driver installation is unable to locate the kernel source. Please make sure that the kernel source packages are installed and set up correctly.

    Can you assist me with that plz?


  26. Yair

    Tried with the windows instances, but i got "msvcr100.dll missing" message when running cudaminer.
    As i wrote before (and can't see my reply here anymore for some reason), on linux I fail to install the nvidia cuda (something with the kernal).
    Can someone help me with this plz?

    Thanks again for the details on how to do this.

  27. null

    I'm getting the same kernel source error after following all the steps and using the exact same AMI.

  28. Rob

    Hello, I'm having problems to compile CudaMiner

    make[2]: nvcc: Command not found
    make[2]: *** [salsa_kernel.o] Error 127
    make[2]: Leaving directory `/home/ec2-user/CudaMiner'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/ec2-user/CudaMiner'
    make: *** [all] Error 2

  29. Alan

    When I run this block of commands

    git clone
    cd CudaMiner
    git reset –-hard 88c6da6d5c2b798d1de7031e8dbcc2678f635e4b
    PATH=/usr/local/cuda-5.5/bin:$PATH make

    it runs then after PATH=/usr/local/cuda-5.5/bin:$PATH make it gets stuck after something saying "spinlock.kernel" and I get "Unreachable Executed" error. Anyone else getting this and does anyone know a fix?

  30. Derek Redfern

    For people having trouble with installing CUDA (fails with some complaint about the kernel source), here's the fix I found… The kernel source in /usr/src/kernels wasn't the same version as the kernel I was running (which you can find with `uname -r`). I went into /boot/grub/menu.lst and made sure that the only enabled kernel version was the one I had the source for.

    Worked like a charm.

  31. Jamone Kelly

    Whenever I run the reset command, I get something along the lines of..

    $ git reset –-hard 88c6da6d5c2b798d1de7031e8dbcc2678f635e4b
    fatal: ambiguous argument '–-hard': unknown revision or path not in the working tree.
    Use '–' to separate paths from revisions, like this:
    'git […] — […]'

  32. Alan

    Yeah CudaMiner doesn't compile even with the git reset for me. Maybe it's because cuda toolkit 5.5 is being installed instead of 5.0. Can anyone update the tutorial?

  33. Brendan

    I've created a simple mining Community AMI on Amazon to get people started. All the instructions are there, for mining to the middlecoin pool.
    The image is called Simple Cryptocoin Miner (ami-9a680caa) it's available in Oregon

  34. SFJelly

    I know someone mentioned this already, but there don't appear to be any g2.2xlarge spot instances available with that AMI. Would the c3.8xlarge be a suitable alternative?

  35. jimothy jimmers

    Just to point out, for those people with errors about finding the kernel, run the following code and then retry:

    yum -y install kernel-devel-`uname -r` kernel-headers-`uname -r`

Leave a Reply

Your email address will not be published. Required fields are marked *