Monday, July 10, 2017

Ethereum mining on AWS

  • Ethereum mining works only on g2.2xlarge or g2.8xlarge instances with Ubuntu 14.04 or later
  • Port 30303 must be opened for both TCP and UDP connections from `anywhere` (in security group settings)
  • Default Ubuntu available with ec2 is minimal i.e. some drm files required for the OS to see GPU drivers are missing. SSH into your machine and run following steps to fix this:
> sudo apt-get install linux-generic  
(Click OK for default option/s when prompted)
> sudo reboot
  • Download CUDA drivers for ec2 instances (use Nvidia units). Working with .deb package (instead of .run) is easier (local or network makes no difference) 
> wget

(Newer versions are available here)

> sudo dpkg -i <cuda repo package>
> sudo apt-get update
> sudo apt-get install cuda
  • Run the following command to check driver is installed: 
> lshw -c video
  • A line that starts with "Configuration:" should mention "...driver=nvidia...", if it doesn't search carefully or try reboot. 
  • If you see "...driver=nouveau..." instead of "...driver=nvidia..." then something is wrong - google how to get rid of it and reinstall cuda.
  • Build geth from source, refer here 
  • run geth to allow it to catch up on the chain: 
> ~/go-ethereum/build/bin/geth
  • install ethminer from cpp-ethereum dev PPAs, refer here 
  • Use following command to check the current hash rate (~6 MH/s) and benchmark ethminer to check that your system is in order: 
> ethminer -G -M 
  • When geth catches up on the blockchain, use the following command to generate a new account: 
> ~/go-ethereum/build/bin/geth account new
  • start geth again with RPC enabled by using command-line below 
> ~/go-ethereum/build/bin/geth --rpc
  • Execute following command to start ethminer
> ethminer -G
  • If using larger g2 instance with 4 GPUs, ethminer needs to be started 4 times. Each time adding a "--opencl-device <0..3>" argument
  • Check logs carefully, ethminer should be getting work packages from geth and be "mining a block"