- GPU Mining on Google Cloud 分享 -
王銘德 @mingderwang
集先鋒
以太坊
2018 FPU edition
王銘德, 集先鋒有限公司 (ELK as a Service)
Taipei Ethereum Meetup
Taipei DevOps Meetup
GCPUC.TW
Docker Taipei Meetup
比特幣, ” 以太幣 “ 都是一種架構在 blockchain 上的虛擬幣
台灣的銀行
100 + 220 = 320 台幣 +
美國的銀行 USD18 = 594 台幣
Tx Cost
0.00042 * 10 * 33 = 0.14 台幣
The Cost of Remit Some Money to US
* 還有, PayPal 也是過氣, 2.9% 手續費 + 30 cents, 瘋了!跟信用卡 (Visa, MasterCard) 一樣貴了
May 22, 2010, 10,000 比特幣只值 $40, 只能買兩個 pizzas. 現在值台幣 357,109,805, 三億五千多萬, 可以買 3~4 台 Bugatti Chiron 跑車
2017
2010
de-centralized 設計 (p2p)
docker tag mingder78/parity asia.gcr.io/winter-wonder-647/instance-parity
gcloud docker -- push asia.gcr.io/winter-wonder-647/instance-parity
sha256:c6818af08c9763d2b360eb118995794d965ed76aa92d897989080ffa3d592a79 size: 2197
gcloud docker -- push asia.gcr.io/winter-wonder-647/instance-parity
c6818af08c97
gcloud docker -- push asia.gcr.io/winter-wonder-647/instance-parity
4 x 8 = 32 個 NVIDIA K80
其實我們只需要 2GB GDDR5 each core (10GB 浪費掉了)
GPUs 不能 attach 到 Preemptible Instances
* 相同的 Project, Instance 裡 docker 抓不到自己的 gcr
$ METADATA=http://metadata.google.internal/computeMetadata/v1
$ SVC_ACCT=$METADATA/instance/service-accounts/default
$ ACCESS_TOKEN=$(curl -H 'Metadata-Flavor: Google' $SVC_ACCT/token \
| cut -d'"' -f 4)
$ docker login -e 1234@5678.com -u _token -p $ACCESS_TOKEN https://gcr.io
$ docker run --rm gcr.io/<your-project>/<your-image> <command>
經過自我授權後, 抓到 docker images 了
加 volume 跟 port 的參數, 改 google firewall 開放 8545
sudo docker run -it -v /var/parity/mainnet:/root/.parity -p 8545:8545 -p 8080:8080 -p 8180:8180 -n my-parity mingder78/instance-parity oot/.parity -p 8545:8545 -p 8080:8080 -p 8180:8180 -n my-parity mingder78/instance-parity
re-sync from #3356450 to 5611447 (now in 5/14/2018)
1 ether = 50 USD to "707" now.
成功透過該 Ethereum node 查詢到第 48 個 block 的資料
第 48 個 block 的 Mined By: 0x1b70474b ... 相同
了解整個 Ethereum Blockchain 的所有交易和紀錄
(例如, 查詢現在最近一個 block 是幾號)
(Proof of work)
沒有適當的鼓勵或誘因, 誰會願意架設 node 來維持共同帳本的運作 ?
10 mins per block
1 BTC ~= 417 USD
Adam Back hashcash
HR: 1,201,761,024 GH/s
Diff: 165,496,835,118
Block Reward: 25 BTC
Reward: 12.50 (in 2017)
BTC
0.0000968 US$ (R7 240 card)
15 sec per block
1 ETH ~= 10 USD
Ethash (a modified version of Dagger-Hashimoto )
HashRate (1,443 GH/s)
Diff: 21.04 TH/s (from 8)
Block Reward: 5.00588 ETH
Ether, Gas, Uncle?, Wei
12.5 US$/ 月 (R7 240 card)
10 mins per block
1 BTC ~= 1,147 USD
Adam Back hashcash
HR: 3,799,849,871 GH/s
Diff: 499,635,929,817
Block Reward: 12.5 BTC
不能寫 smart contracts
BTC
0.0003441 US$ (R9 720 card)
15 sec per block
1 ETH ~= 50 USD
Ethash (a modified version of Dagger-Hashimoto )
HashRate (16,016.45 GH/s)
Diff: 223.89 TH/s
Block Reward: 5.01321 ETH
可以寫 Smart contracts
Ether, Gas, Uncle?, Wei
82 US$/ 月 (R9 720 card)
從年初 1 Ether = 9.85 美金, 3 月中漲到 50 美金
買繪圖卡來 mining 還便宜, 價格好就自動挖, 價格不好就停
GPU
19.43 MH/s
??? MH/s
ROI ???
在 Google Computer Engine 裡先安裝 geth 與 ethminer. 在把 snapshot 起來, 可以利用 snapshot 開啟 GPU instance.
"Attaching GPUs to Instances"
誤導了我 !!!
只有以下幾個 Data Centers 有 GPUs
重頭開始 sync 3,466,539 blocks (至少需三天三夜)
$ docker commit a9f asia.gcr.io/winter-wonder-647/instance-parity:block_3466539
$ gcloud docker -- push
asia.gcr.io/winter-wonder-647/instance-parity:block_3466539
把舊的 blocks 直接包在 docker images 裡 (但安全嗎?)
Got work package:
miner 05:41:58.936|ethminer Header-hash: e7e70f40cd84dc6a156cefa09d155407cc24d2c2325cf625cfb9c0df8fe031d5
miner 05:41:58.936|ethminer Seedhash: fd8498fade3673e1123a9d82267a3e966bd05069e9933ed95a8cd9c35f7d85d4
miner 05:41:58.936|ethminer Target: 0000000000015c55b42af7f2b8747f86904b8326ea66b34587106cb67e7dda06
越少 0 的人贏 (14 秒內) -> 獎金約 NTD$7,500
GPU driver
0 H/s -> 12552014 H/s (6291456 hashes / 0.544 s)
當然還要跟所有的 miners 比 (運氣)
發現 CPU and memory is my limitation !!
8 CPUs
7.2 GB 就夠了
(1 Ether = 11 USD 來推算)
312.69 MH/s
( 好玩就好 )
https://medium.com/decentralized-capital/setting-up-a-parity-ethereum-node-in-docker-and-connect-safely-f881faa17686
https://github.com/ethereum/wiki/wiki/JavaScript-API
https://medium.com/google-cloud/running-jupyter-notebooks-on-gpu-on-google-cloud-d44f57d22dbd