貌似很多人都是在windows下挖矿。

用Linux挖还真是个技术活

首先在Ubuntu 16.04的桌面选software & updates-->additional drivers

这里装上了nvidia的binary driver--387.26

ok

然后去https://developer.nvidia.com/cuda-downloads,按自己的选项,选择deb(local)

然后装cuda的deb包,按自己的包安装pub key,更新源,升级,安装cuda-toolkit-9-1

dpkg -i cuda-repo-ubuntu1604-9-1-local_9.1.85-1_amd64.deb  
apt-key add /var/cuda-repo-9-1-local/7fa2af80.pub  
apt-get update  
apt-get upgrade  
apt-get install cuda-toolkit-9-1  

这里有个大坑,本来八戒的ubuntu是禁止了系统升级的,所以cuda9.1怎么也装不上,提示包依赖错误,后来打开了系统自动升级,才好,大家要注意。

测试一下cuda是否正确,运行deviceQuery后看到结果“Result = PASS” 就表明cuda没问题了

cd /usr/local/cuda/samples/1_Utilities/deviceQuery && sudo make  
/usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery

然后下载项目xmr-stak

sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev  
git clone https://github.com/fireice-uk/xmr-stak.git  
mkdir xmr-stak/build  
cd xmr-stak/build  
cmake .. -DOpenCL_ENABLE=OFF # Added the flag, otherwise I'd have to install OpenCL  
make install  

哈哈哈,编译到80%的时候报错

......
[ 76%] Built target xmr-stak-backend
[ 80%] Building NVCC (Device) object CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_extra.cu.o
/home/mryukeen/Documents/xmr-stak/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu:9:32: fatal error: device_functions.hpp: No such file or directory
compilation terminated.  
CMake Error at xmrstak_cuda_backend_generated_cuda_extra.cu.o.cmake:207 (message):  
  Error generating
  /home/mryukeen/Documents/xmr-stak/build/CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/./xmrstak_cuda_backend_generated_cuda_extra.cu.o


CMakeFiles/xmrstak_cuda_backend.dir/build.make:70: recipe for target 'CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_extra.cu.o' failed  
make[2]: *** [CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_extra.cu.o] Error 1  
CMakeFiles/Makefile2:142: recipe for target 'CMakeFiles/xmrstak_cuda_backend.dir/all' failed  
make[1]: *** [CMakeFiles/xmrstak_cuda_backend.dir/all] Error 2  
Makefile:127: recipe for target 'all' failed  
make: *** [all] Error 2  

我就去了,改,先把当前用户的路径和环境变量弄对了,然后重新登录

sudo usermod -a -G video $USER  
echo "" >> ~/.bashrc  
echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc  
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> ~/.bashrc  

继续编译还是报错,看来需要修改一下源代码,把xmrstak/backend/nvidia/nvcccode/cudaextra.cu的代码中第九行删除

#include <device_functions.hpp>

用shell脚本直接搞定

cd xmr-stak  
sed -i '9d' xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu  

然后再编译就可以通过了,注意,会花很长时间才会编译成功。

然后运行xmr-stak,会问你配置,注意poll_address,推荐us.moriaxmr.com:5555,手续费0.2,比较低,password的格式是workid:邮箱地址

"pool_address" : "us.moriaxmr.com:5555", 
"pool_password" : "q:bajie@gmail.com", 

注意修改cpu.txt和nvidia.txt文件,缺省是疯狂挖矿模式,实际只用1半cpu比较好,八戒的cpu是i7-4790k,虚拟8核的,只用4个就够了

cpu.txt  
"cpu_threads_conf" :
[
    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 0 },
    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 1 },
    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 2 },
    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 3 },
],

nvidia.txt  
"gpu_threads_conf" : [ { "index" : 0, "threads" : 42, "blocks" : 8, "bfactor" : 8, "bsleep" : 100, "affine_to_cpu" : true, },],

然后开挖,https://moriaxmr.com:8443/#/dashboard可以查看挖矿的状况 登录的时候输入自己的钱包地址和邮箱地址就可以了

comments powered by Disqus