Mining Ethereum on GCP

By August 5, 2022Ethereum
Click here to view original web page at

ETH mining will be gone in a month or two when the Ethereum network migrates to the long anticipated Proof-of-Stake model. While now it no longer makes sense to buy GPUs and build mining rigs it’s still perfectly possible to mine on the Google Cloud Platform.

Photo by Kanchanara on Unsplash

In the previous posts I have introduced an easy way to mine Ethereum (ETH) crypto currency on the AWS platform. Many readers asked me whether the same can be done on GCP, the popular Google Cloud Platform. Of course it can be done! GCP also offers VM instances with NVidia GPU cards — namely Tesla T4, Tesla V100 and the super fast Tesla A100 — and we can use them for ETH mining.

Today I’m introducing you the GCP Ethereum Miner!

Before we jump onto it let me emphasise two points:

  • GCP is quite sensitive about crypto mining on their platform. The scripts and templates presented here have been carefully crafted to bypass their detection, however as always run it at your own risk.
  • Ethereum mining may not be profitable at all times and your GCP bill can get very expensive very quickly and the ETH returns may not necessarily cover the costs. You have been warned!

What is GCP Ethereum Miner?

  • It’s a ready to go Terraform template that spins up pre-configured VM instances that automatically join the mining pool and start mining.
  • Can be deployed from Google Cloud Shell for convenience.
  • Maintains the mining farm across all the available regions and GPU types. If any VM is taken out of services it will automatically be replaced.
  • Supports both Spot and Standard provisioning models. You can choose to start the VMs in either or both, depending on your budget and quotas.

Quick start ETH mining on GCP

Setting up mining using the GCP Ethereum Miner is really easy. Let’s start with some prerequisites:

  • Obviously you need a GCP account with a “Project” set up, and that “Project” must have high enough Quotas for NVidia GPUs. The former is easy, anyone can open a new account and create a new project. The latter is not that easy — GCP is quite reluctant to approve GPU quota increases without a good justification. However you may be lucky or you may already be in a possession of an established account / project with high quotas. Good on you then! More on this below.
  • Then you need an Ethereum Wallet Address to which the mining rewards will be sent. If you don’t already have an Ethereum wallet I suggest that you check out MetaMask — it’s a browser extension that offers a number of useful features. The main one relevant to our use-case is that it’s a Web3-compatible wallet that can be used to configure the payouts from the mining pool.

Now that we’ve got the pre-reqs sorted we’re ready to jump onto it!

Open the Cloud Shell

Once you are in the Google Cloud console open the Cloud Shell.

When it starts up make sure that you’ve got your mining project active. Let’s say the project is called miner-project-12345

cloudshell:~$ gcloud config set project miner-project-12345
Updated property [core/project].
cloudshell:~ (miner-project-12345)$

You may be presented with a dialog asking for authorisation — click Authorise.

Clone the GitHub repository

The next step is to clone and configure the GCP miner GitHub repository:

cloudshell:~ (miner-project-12345)$ git clone \
Cloning into 'gcp-ethereum-miner'...
remote: Enumerating objects: 41, done.
remote: Counting objects: 100% (41/41), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 41 (delta 23), reused 39 (delta 21), pack-reused 0
Receiving objects: 100% (41/41), 5.80 KiB | 2.90 MiB/s, done.
Resolving deltas: 100% (23/23), done.cloudshell:~ (miner-project-12345)$ cd gcp-ethereum-miner
cloudshell:~/gcp-ethereum-miner (miner-project-12345)$

Don’t forget to configure the parameters in terraform.tfvars file. Most notably you will want to update the Ethereum Wallet address (though feel free to mine to mine :)

# terraform.tfvars# Ethereum wallet address
wallet_address = "0x99b36B44cf319c9E0ed4619ee2050B21ECac2c15"# Launch instances in these provisioning models
provisioning_models = ["SPOT", "STANDARD"]
# provisioning_models = ["SPOT"]# GPU types to use
gpu_types = ["t4", "a100", "v100"]
# gpu_types = ["t4"]# Number of instances per-gpu / per-region / per-provisioning_model
group_size = 16

Depending on your budget you may want to only use the SPOT instances for better cost efficiency, or both SPOT and STANDARD if you prefer to spin up as many instances as possible for a faster mining. Likewise you may want to restrict mining only to NVidia Tesla T4 cards which are more cost effective than NVidia Tesla A100 or V100. But again if you prefer to mine fast regardless of the efficiency you can leave the gpu_types setting as is.

Start mining!

Finally! It’s time to deploy the template and start mining. Google Cloud Shell comes with Terraform pre-installed so all we have to do is initialise it and then apply, which means deploy in terraform terminology.

~/gcp-ethereum-miner (miner-project-12345)$ terraform init
~/gcp-ethereum-miner (miner-...)$ terraform apply -auto-approve

It will take a while to create the Instance Templates, the Instance Groups and finally the VM instances. If everything goes all right you should see some VMs starting up across regions…

GCP Ethereum Miner — VM instances

Each VM takes about 3 to 4 minutes to spin up, self-configure and start mining. After that it joins the Ethremine mining pool and eventually, 15 to 20 mins later, you should being to see your pool hash rate slowly go up. It may take another hour or two for all the VMs to start up and for the Ethermine dashboard to show the actual hashrate.

Ethermine dashboard

GPU Quotas

What if you don’t see any VMs running even after a long time waiting? First of all check out the Instance Group’s ERRORS tab to see what’s going on.

GPU quotas exceeded

All cloud platforms have a concept of “Service Quotas” — they won’t let you spin up an unlimited number of resources, even if you want to pay for them. One reason is your own protection — what if a runaway automation script spins up hundreds or thousands of instances and before you notice you go broke? The low quotas may save your day.

The other reason is to moderate the demand. Some resources — like GPUs — are in a high demand from AI/ML users, graphics and video rendering users and of course from the crypto miners. GCP therefore uses Quotas to try to give everyone access to at least some GPUs.

Unfortunately new accounts and new projects typically have the quota set to 0 and can’t use any GPUs at all. None. Zilch. Your only chance in that case is to convince the GCP support to increase it. Needless to say that “Crypto mining” is not a good justification :))

You will have to check and try to increase quotas for GPUS_ALL_REGIONS, PREEMTIBLE_NVIDIA_T4_GPUS, …_V100_GPUS, …_A100_GPUS, etc. And all that in all the regions where you want to mine. I suggest you start low — ask for an increase from 0 to 4 for example as that’s more likely to be approved than a big jump to 20, or 100 or more.

Known issues

  • The need to conceal the mining from GCP increases the latency between the miners and the pool. As a result there may be elevated percentage of “Stale shares” at some times. Between 5% to 15% of stale shares is quite normal.
  • Configuring the payout thresholds in Ethermine requires authorisation either by a Web3 wallet or by entering the IP of the “best performing worker”. However due to manipulating the network traffic to bypass GCP detection we don’t know the IP. Hence the recommendation to use the MetaMask wallet and use that to configure the payouts.
  • Profitability is obviously questionable. Do you own research and don’t forget that cloud mining can get very expensive very quickly.

Subscribe to my Ethereum Miner mailing list to stay up to date.

Happy mining! ;-)

Also check out my previous posts on this topic. Some prices and profitability calculations are now out of date but you can still find a lot of useful background information in there!

All Today's Crypto News In One Place