Skip to main content

Litecoin mining using AWS EC2 and CUDA - Part2

The part1 of the tutorial discussed about setting up a powerful GPU machine for bitcoin mining. Please refer to the link here if you need to go through it.

Assuming you have  AWS GPU machine available, login to the server from your laptop/Desktop. Here I am using my Apple Mac Book Pro.

ssh ubuntu@52.207.xxx.xx -i MyVPCKeypair.pem

Next install all updates. This is a good practice whenever you first login to a EC2 instance.

~$ sudo apt-get update

Then installed a set of dependencies, I am not sure whether all of them are needed.

sudo apt-get install -y freeglut3-dev libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev gcc make libcurl4-openssl-dev autoconf git screen libncurses5-dev opencl-headers build-essential protobuf-compiler libprotoc-dev libboost-all-dev libleveldb-dev hdf5-tools libhdf5-serial-dev libopencv-core-dev libopencv-highgui-dev libsnappy-dev libsnappy1v5 libatlas-base-dev cmake libstdc++6-4.9-dbg libgoogle-glog0v5 libgoogle-glog-dev libgflags-dev liblmdb-dev python-pip gfortran libjansson-dev uthash-dev autogen libtool pkg-config

Install NVIDIA driver by following steps.

wget http://us.download.nvidia.com/XFree86/Linux-x86_64/375.20/NVIDIA-Linux-x86_64-375.20.run

chmod +x NVIDIA-Linux-x86_64-375.20.run

sudo ./NVIDIA-Linux-x86_64-375.20.run 

Then install

sudo apt install ubuntu-drivers-common

sudo ubuntu-drivers autoinstall

Now get CUDA and install/update

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.44-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb 

sudo apt-get update

sudo apt-get install cuda

Install SSL package

sudo apt-get install libssl-dev

Get CudaMiner

git clone https://github.com/cbuchner1/CudaMiner

Make CudaMiner using below steps

cd CudaMiner/
./configure.sh
 make

Here I am getting below error
/usr/local/cuda/bin/nvcc -O3 -Xptxas "-abi=no -v" -arch=compute_10 --maxrregcount=64 --ptxas-options=-v  -o salsa_kernel.o -c salsa_kernel.cu
nvcc fatal   : Value 'compute_10' is not defined for option 'gpu-architecture'
Makefile:946: recipe for target 'salsa_kernel.o' failed
make[2]: *** [salsa_kernel.o] Error 1
make[2]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:496: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:285: recipe for target 'all' failed

make: *** [all] Error 2


To fix this issue open Makefile and modify all 'compute_10' to 'sm_30'.

Try ./configure.sh followed by  make

Now I am getting below error

ptxas error   : Invalid value 'no' for option -abi.
ptxas fatal   : Ptx assembly aborted due to errors
Makefile:946: recipe for target 'salsa_kernel.o' failed
make[2]: *** [salsa_kernel.o] Error 255
make[2]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:496: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:285: recipe for target 'all' failed

make: *** [all] Error 2

To fix this edit Makefile and change "-abi=no" to "-abi=yes"

Try ./configure.sh followed by  make

Now again error

/usr/bin/ld: cudaminer-cpu-miner.o: undefined reference to symbol 'SHA256@@OPENSSL_1.0.0'
//lib/x86_64-linux-gnu/libcrypto.so.1.0.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:376: recipe for target 'cudaminer' failed
make[2]: *** [cudaminer] Error 1
make[2]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:496: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/CudaMiner'
Makefile:285: recipe for target 'all' failed
make: *** [all] Error 2

To fix this run
./autogen.sh

Try ./configure.sh followed by  make. Finally this time no errors.

Run cudaminer and see whether it is coming up.

./cudaminer 
   *** CudaMiner for nVidia GPUs by Christian Buchner ***
             This is version 2014-02-28 (beta)
based on pooler-cpuminer 2.3.2 (c) 2010 Jeff Garzik, 2012 pooler
    Cuda additions Copyright 2013,2014 Christian Buchner
  LTC donation address: LKS1WDKGED647msBQfLBHV3Ls8sveGncnm
  BTC donation address: 16hJF5mceSojnTD3ZTUDqdRhDyPJzoRakM
  YAC donation address: Y87sptDEcpLkLeAuex6qZioDbvy1qXZEj4
[2017-12-13 17:12:50] NVML GPU monitoring is not available.
[2017-12-13 17:12:50] 1 miner threads started, using 'scrypt' algorithm.
[2017-12-13 17:12:50] HTTP request failed: Failed to connect to 127.0.0.1 port 9332: Connection refused
[2017-12-13 17:12:50] json_rpc_call failed, retry after 15 seconds

Even though there is an error we can see that cudaminer is coming up which is a good sign.


For Bitcoin mining you can choose one of the two options which are solo mining and joining a pool. I chose to join a mining pool.

You can choose from  many available mining pools. Here in this tutorial I chose give me coins. Go to https://give-me-coins.com, sign up and create an account. You will see a dashboard similar to this.



Once logged in then go to Account->workers and create a worker.


Now we need to create a coin wallet to securely store our litecoin or bitcoin or other coins. You can use any wallet service. I used Jaxx. jaxx  can be installed from https://jaxx.io. Once installed then go to LTC tab and copy the wallet address to clipboard. Remember each coin has different wallet address and make sure that you copy the correct one.

In  https://give-me-coins.com go to Accounts->Settings->Profile and update 'LTC Wallet Address' with the Jaxx LTC wallet address.

Go to Support->Pool Servers and select a URL of the server according to your region. I chose 'ltc.give-me-coins.com:3333'.

Now start cudaminer by providing worker details and server info.

./cudaminer -O jineshmathewt.user:pass -o stratum+tcp://ltc.give-me-coins.com:3334 -D

Note
username :jineshmathewt.user 
password:pass
server URL:ltc.give-me-coins.com:3334
-D for debug or detailed logs on console

I see console logs like below

./cudaminer -O jineshmathewt.user:pass -o stratum+tcp://ltc.give-me-coins.com:3334 -D
   *** CudaMiner for nVidia GPUs by Christian Buchner ***
             This is version 2014-02-28 (beta)
based on pooler-cpuminer 2.3.2 (c) 2010 Jeff Garzik, 2012 pooler
    Cuda additions Copyright 2013,2014 Christian Buchner
  LTC donation address: LKS1WDKGED647msBQfLBHV3Ls8sveGncnm
  BTC donation address: 16hJF5mceSojnTD3ZTUDqdRhDyPJzoRakM
  YAC donation address: Y87sptDEcpLkLeAuex6qZioDbvy1qXZEj4
[2017-12-13 17:36:32] NVML GPU monitoring is not available.
[2017-12-13 17:36:32] 1 miner threads started, using 'scrypt' algorithm.
[2017-12-13 17:36:32] Starting Stratum on stratum+tcp://ltc.give-me-coins.com:3334
[2017-12-13 17:36:32] Stratum session id: 050500001
[2017-12-13 17:36:32] Stratum difficulty set to 131072
[2017-12-13 17:36:32] DEBUG: job_id='1513186582 14467' extranonce2=00000000 ntime=5a316516
[2017-12-13 17:36:33] GPU #0: Tesla M60 with compute capability 5.2
[2017-12-13 17:36:33] GPU #0: interactive: 0, tex-cache: 0 , single-alloc: 0
[2017-12-13 17:36:33] GPU #0: 32 hashes / 4.0 MB per warp.
[2017-12-13 17:36:33] GPU #0: Performing auto-tuning (Patience...)
[2017-12-13 17:36:33] GPU #0: maximum total warps (BxW): 1843
[2017-12-13 17:36:34]        x1    x2    x3    x4    x5    x6    x7    x8    x9   x10   x11   x12   x13   x14   x15   x16   x17   x18   x19   x20   x21   x22   x23   x24 
[2017-12-13 17:36:34]   8: 15.0| 33.0| 54.4| 

[2017-12-13 17:47:31] GPU #0: 368016.27 hash/s with configuration T28x20
[2017-12-13 17:47:31] GPU #0: using launch configuration T28x20
[2017-12-13 17:47:32] GPU #0: Tesla M60, 387.94 khash/s
[2017-12-13 17:47:47] DEBUG: hash <= target
Hash:   0000007a7e158c8b24b898e852279209be4b69b4bc550e2cd2a17dd8fdf76364
Target: 000000ffff000000000000000000000000000000000000000000000000000000
[2017-12-13 17:47:47] GPU #0: Tesla M60, 362.88 khash/s
[2017-12-13 17:47:48] accepted: 1/1 (100.00%), 362.88 khash/s (yay!!!)

[2017-12-13 17:47:49] DEBUG: job_id='1513187269 14482' extranonce2=00000000 n


Now the mining has started , we have joined the litecoin mining pool and the run is going on.

https://give-me-coins.com dashboard will be updated with your hashing details. This would take an hour or so to update, be patient.

Now let us see the profitability of this mining. If you go to https://give-me-coins.com Calc and provide your hashing rate. This will tell you the profit you are going to make.


Most of the cases AWS charge would be more than the amount of litecoin that you are going to make and therefore mining is not profitable. But it is a great way to learn something new.

Make sure that you terminate the AWS EC2 instance soon after you are done with the experiment to avoid unexpected charges.

Happy Learning..... Thanks for your time. 

Comments

Popular posts from this blog

How to format and install macOS in your old Macbook/ iMac

 You can follow these steps to install a mac OS on an old Mac book following these steps. Here I assume that you have the actual bootable CD for the OS for installation. 1. Restart the laptop 2. Press Command + R key until it shows recovery mode 3. Open Disk Utilities 4. Select the hard drive and try to partition the drive. For example I have created a partition called Partition1 5. Insert bootable CD and restart the laptop. When option comes choose to boot from the CD. 6. Choose partition1 as the place to install the OS 7. Continue the installation process. 8. Once installation is completed then it might need to restart for further updates. 9. Most of the times a more recent compatible version of the OS might be available. In order to upgrade to the more latest compatible OS follow below steps. 11. Find the latest compatible version of OS. 12. Go to apple support sites and manually download the image and click to install. 13. Follow installation instructions and this would upgrade you

How to create a minikube single node cluster for learning Kubernetes

In this post I will explain how to setup a minikube single node kubernetes cluster using AWS EC2 instance which would help anyone who is trying to learn kubernetes and also help them to gain practical knowledge in kubernetes by running kubernetes commands, creating kubernetes objects etc. Minikube is a single node kubernetes cluster which means a kubernetes cluster with only one node that is a single VM. Minikube is only used for learning purposes and it is not an alternative for a real kubernetes cluster and should not be used for development and production usage. In this example I have launched an AWS EC2 instance with below configuration where I will install minikube and related tools. AWS EC2 Instance Configuration AMI: Ubuntu Free tier eligible 64 bit Instance type : t2-large ( For me t2-small or t2-micro is giving performance issues due to less memory) Once the EC2 instance is up and running, login to the instance using below command on terminal. If you are using wi

log4j - How to write log to multiple log files using log4j.properties

In Java applications some times you may need to write your log messages to specific log files with its own specific log properties. If you are using log4j internally then first step that you need to do is to have a proper log4j.properties file. Below example shows 2 log4j appenders which write to 2 different log files, one is a debug log and another one is a reports log. Debug log file can have all log messages and reports log can have log messages specific to reporting on say splunk monitoring. # Root logger option log4j.rootLogger=ALL,STDOUT,debugLog log4j.logger.reportsLogger=INFO,reportsLog log4j.additivity.reportsLogger=false     log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout log4j.appender.STDOUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%L - %m%n     # Direct log messages to a log file log4j.appender.debugLog=org.apache.log4j.RollingFileAppender log4j.appender.debugLo