Mining Ethereum on M1 Mac GPU

TL;DR: It’s possible to mine Ethereum on a M1 Mac GPU. Hashrate is about 2Mh/s.

Mining on a M1 Mac

I’ve had my M1 MacBook Air for a bit of time now, and I also recently started mining Ethereum. I can’t help asking myself: What’s Ethereum mining performance like on a M1 Mac?

The obvious thing to do first is to run the off-the-shelf ethminer, which gives the following error:

ethminer 0.19.0-alpha.0
Build: darwin/release/appleclang

Unrecognized platform Apple
Error: No usable mining devices found

Not good. Apparently Apple GPUs are not whitelisted in ethminer. That should be easy to fix. Relevant lines are in libethash-cl/CLMiner.cpp, and I added Apple GPUs to the whitelist, pretending it’s an Intel GPU.

Then boost won’t compile since it’s trying to compile with a -fcoalesce-templates argument, which doesn’t exist in recent clang versions. So I have to update boost to the latest version, and fix relevant asio code since ethminer was using deprecated asio APIs.

I also need to upgrade OpenSSL to the latest version to have it support darwin + arm64.

After getting everything to compile. Here’s the result:

ethminer 0.19.0-17+commit.ce52c740.dirty
Build: darwin/release/appleclang

 i 19:51:36          Configured pool eth-us-east1.nanopool.org:9999
 i 19:51:36          Selected pool eth-us-east1.nanopool.org:9999
 i 19:51:36          Connection remotely closed by eth-us-east1.nanopool.org
 i 19:51:36          Stratum mode : EthereumStratum/1.0.0 (NiceHash)
 i 19:51:36          Established connection to eth-us-east1.nanopool.org [144.217.14.139:9999]
 i 19:51:36          Spinning up miners...
cl 19:51:36 cl-0     Using Device : Intel GPU 0.0 Apple M1 OpenCL 1.2  Memory : 10.67 GB (11453251584 B)
 i 19:51:36          Extranonce set to 778d
 i 19:51:36          Extranonce set to 778d
 i 19:51:36          Authorized worker [REDACTED]
 i 19:51:36          Epoch : 397 Difficulty : 10.00 Gh
 i 19:51:36          Job: c7fc5311… eth-us-east1.nanopool.org [144.217.14.139:9999]
cl 19:51:38 cl-0     Generating split DAG + Light (total): 4.10 GB
 i 19:51:38          Job: 40a57756… eth-us-east1.nanopool.org [144.217.14.139:9999]
cl 19:51:38 cl-0     OpenCL kernel
cl 19:51:38 cl-0     Creating DAG buffer, size: 4.10 GB, free: 6.57 GB
cl 19:51:38 cl-0     Creating light cache buffer, size: 65.62 MB
cl 19:51:38 cl-0     Loading kernels
cl 19:51:38 cl-0     Creating buffer for header.
cl 19:51:38 cl-0     Creating mining buffer
 m 19:51:41          0:00 A0 0.00 h - cl0 0.00
 i 19:51:42          Job: 077b62f6… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:51:46          0:00 A0 0.00 h - cl0 0.00
 i 19:51:46          Job: 2835839e… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:51:51          0:00 A0 0.00 h - cl0 0.00
 m 19:51:56          0:00 A0 0.00 h - cl0 0.00
 i 19:51:57          Job: 97f724e7… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:52:01          0:00 A0 0.00 h - cl0 0.00
 m 19:52:06          0:00 A0 0.00 h - cl0 0.00
 m 19:52:11          0:00 A0 0.00 h - cl0 0.00
 m 19:52:16          0:00 A0 0.00 h - cl0 0.00
 i 19:52:16          Job: 54df0504… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:52:21          0:00 A0 0.00 h - cl0 0.00
cl 19:52:22 cl-0     4.10 GB of DAG data generated in 44,060 ms.
 m 19:52:26          0:00 A0 184.16 Kh - cl0 184.16
 m 19:52:31          0:00 A0 1.96 Mh - cl0 1.96
 m 19:52:36          0:01 A0 1.98 Mh - cl0 1.98
 i 19:52:39          Job: d3b1da5e… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:52:41          0:01 A0 1.99 Mh - cl0 1.99
cl 19:52:43 cl-0     Job: 54df0504… Sol: 0x778d000001d14c71
 i 19:52:43          **Accepted 150 ms. eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:52:46          0:01 A1 1.95 Mh - cl0 1.95
 m 19:52:51          0:01 A1 2.07 Mh - cl0 2.07
 m 19:52:56          0:01 A1 2.00 Mh - cl0 2.00
 m 19:53:01          0:01 A1 1.98 Mh - cl0 1.98
 i 19:53:01          Job: ccc2b97f… eth-us-east1.nanopool.org [144.217.14.139:9999]
 m 19:53:06          0:01 A1 1.97 Mh - cl0 1.97
 i 19:53:07          Job: 23919d82… eth-us-east1.nanopool.org [144.217.14.139:9999]
^C i 19:53:10 main     Got interrupt ...
 i 19:53:10 main     Disconnected from eth-us-east1.nanopool.org [144.217.14.139:9999]
 i 19:53:10 main     Shutting down miners...
 i 19:53:16 main     Terminated!

Code is available at https://github.com/gyf304/ethminer-m1

Is it worth it?

Um. Not really. At current Ethereum prices (2021-02-26), it generates $0.14 of profit per day. It’s still a profit, but very miniscule.

By Yifan Gu

aka. Frank, aka. 顾屹凡