3.2 GPU挖矿

优质
小牛编辑
117浏览
2023-12-01

硬件

该算法是内存困难的,为了将DAG安装到内存中,每个GPU需要1-2GB的RAM。如果你遇到Error GPU mining. GPU memory fragmentation?,那就意味着你内存不足 GPU挖矿也在OpenCL中实现,因此AMD GPU将比同类NVIDIA GPU“更快”。ASIC和FPGA相对效率低下,因此不鼓励。 要获得openCL的芯片组和平台,请尝试:

在Ubuntu上

硬件

下载ADL_SDK8.zipAMD-APP-SDK-v2.9-1.599.381-GA-linux64.sh

./AMD-APP-SDK-v2.9-1.599.381-GA-linux64.sh
ln -s /opt/AMDAPPSDK-2.9-1 /opt/AMDAPP
ln -s /opt/AMDAPP/include/CL /usr/include
ln -s /opt/AMDAPP/lib/x86_64/* /usr/lib/
ldconfig
reboot

apt-get install fglrx-updates
// wget, tar, opencl
sudo aticonfig --adapter=all --initial
sudo aticonfig --list-adapters
* 0. 01:00.0 AMD Radeon R9 200 Series

* - Default adapter

Nvidia

以下说明适应大部分使用Ubuntu 14.04和Nvidia GPU的任何系统。 设置一个EC2实例进行挖掘

在MacOS X上

wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.29_mac.pkg
sudo installer -pkg ~/Desktop/cuda_7.0.29_mac.pkg -target /
brew update
brew tap ethereum/ethereum
brew reinstall cpp-ethereum --with-gpu-mining --devel --headless --build-from-source

你可以检查你的冷却状态:

aticonfig --adapter=0 --od-gettemperature

挖矿软件

geth的官方Frontier版本只支持CPU矿工。我们正在开发一个GPU矿工,但它可能不适用于Frontier版本。不过,Geth可以与ethminer结合使用,使用独立的矿工作为工作人员,geth作为调度程序,他们通过JSON-RPC进行通信。

Ethereum(未正式发布)的C++实现具有GPU矿工。它可以被eth,AlethZero(GUI)和ethMiner(独立矿工)所使用。

您可以通过ppa在linux上安装,通过brew tap在MacOS上安装,或直接从源代码编译安装。

在MacOS上:

brew install cpp-ethereum --with-gpu-mining --devel --build-from-source

在Linux上:

apt-get install cpp-ethereum

在Windows上: https://github.com/ethereum/cpp-ethereum/wiki/Building-on-Windows

结合ethminer的GPU挖矿

用eth挖矿:

eth -m on -G -a <coinbase> -i -v 8 //

从源文件安装ethminer:

cd cpp-ethereum
cmake -DETHASHCL=1 -DGUI=0
make -j4
make install

要设置GPU挖矿,您需要一个coinbase帐户。它可以是本地或远程创建的帐户。

使用ethminer与geth

geth account new
geth --rpc --rpccorsdomain localhost 2>> geth.log &
ethminer -G  // -G for GPU, -M for benchmark
tail -f geth.log

ethminer在端口8545(geth中的默认RPC端口)上与geth进行通信。您可以通过geth上的--rpcport选项来更改。Ethminer会找到任何端口。请注意,您需要使用--rpccorsdomain localhost设置CORS头。您还可以在ethminer上使用 -F http://127.0.0.1:3301设置端口。如果您希望在同一台计算机上实现几个实例挖掘,那么设置端口是必要的,尽管这有点无意义。如果您在私有群集上进行测试,建议您改用CPU。

另外请注意,你无需给geth设置--mine选项,或者在控制台开启旷工,除非你想在GPU挖矿的同时也进行CPU挖矿 除非你想要做的GPU挖掘的TOP CPU挖掘开始矿工在控制台中。 如果默认的ethminer不工作,尝试用--opencl-device X指定OpenCL设备,其中X为0,1,2等。使用ethminer-M(基准)运行时,您应该看到如下信息:

Benchmarking on platform: { "platform": "NVIDIA CUDA", "device": "GeForce GTX 750 Ti", "version": "OpenCL 1.1 CUDA" }

Benchmarking on platform: { "platform": "Apple", "device": "Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz", "version": "OpenCL 1.2 " }

调试 geth:

geth  --rpccorsdomain "localhost" --verbosity 6 2>> geth.log

调试 miner:

make -DCMAKE_BUILD_TYPE=Debug -DETHASHCL=1 -DGUI=0
gdb --args ethminer -G -M

注意:当GPU正在挖矿时,geth的哈希率信息无法获取。查询ethminer的哈希率时,miner.hashrate总是返回0

ethminer和eth

ethminer可以通过rpc和eth结合使用:

eth -i -v 8 -j // -j for rpc
ethminer -G -M // -G for GPU, -M for benchmark
tail -f geth.log

或者你可以使用eth自己执行GPU挖矿:

eth -m on -G -a <coinbase> -i -v 8 //