Skip to content

Instantly share code, notes, and snippets.

@9bitbear
Last active March 22, 2021 10:45
Show Gist options
  • Save 9bitbear/8c350847f82d7f6bc3ec6023c6b32423 to your computer and use it in GitHub Desktop.
Save 9bitbear/8c350847f82d7f6bc3ec6023c6b32423 to your computer and use it in GitHub Desktop.
XMR mining on Ubuntu

CPUminer-multi

Source

Build:

sudo apt-get install git libcurl4-openssl-dev build-essential libjansson-dev autotools-dev automake
git clone https://github.com/hyc/cpuminer-multi
cd cpuminer-multi
./autogen.sh
CFLAGS="-march=native" ./configure
make

Try it:

sudo ./minerd -a cryptonight -o stratum+tcp://pool.minexmr.com:4444 -u WALLET_ADDRESS

Run as service (Systemd setup)

enable service (on startup):

sudo systemctl start xmr-stak.service
sudo systemctl status xmr-stak.service # check for errors
sudo systemctl enable xmr-stak.service # enable for system startup

Systemd docs

XMR-Stak (AMD & NVIDIA GPU mining)

Source / FAQ

Install prereqs

sudo apt install git build-essential libmicrohttpd-dev libssl-dev cmake libhwloc-dev

Download source & Build:

cd ~
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..  ## add -DCUDA_ENABLE=OFF or -DOpenCL_ENABLE=OFF
## or -DOpenCL_INCLUDE_DIR=/opt/amdgpu-pro/lib/x86_64-linux-gnu
## or -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libOpenCL.so -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include/CL
## or -DOpenCL_LIBRARY=/opt/amdgpu-pro/lib/x86_64-linux-gnu/libOpenCL.so -DOpenCL_INCLUDE_DIR=/opt/amdgpu-pro/bin
make install
## if u get error 'CL/cl.h: No such file or directory', try: sudo apt-get install opencl-headers

# quick test
bin/./xmr-stak

Some tips:

cp bin/xmr-stak /usr/local/bin/xmr-stak # so system can execute
/usr/local/bin/xmr-stak -c ~/xmr-stak/config.txt
  • To avoid OUT_OF_MEMORY errors with older cards:
export GPU_FORCE_64BIT_PTR=1
export GPU_USE_SYNC_OBJECTS=1
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100
export GPU_MAX_HEAP_SIZE=100
  • fix for build error: 'CL/cl.h: No such file or directory'
sudo apt-get install opencl-headers

Setup Huge Pages

If you run into issues related to mmap this means you need to enable hugepages. To do this type the following commands:

sudo sysctl -w vm.nr_hugepages=128
sudo nano /etc/sysctl.conf

At the end of the sysctl.conf file add: vm.nr_hugepages=128

[Unit]
Description=XMR-stak service
After=network.target
[Service]
Type=simple
GuessMainPID=no
ExecStart=/usr/local/bin/xmr-stak -c /home/miner/xmr-stak/config.txt --amd /home/miner/xmr-stak/amd.txt
Restart=on-failure
User=miner
[Install]
WantedBy=multi-user.target

XMRig

Source

Build executable

sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev
git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..
make
cp xmrig /usr/local/bin/xmrig # so system can execute

Run as service (Systemd setup)


optional:

  • For AMD/OpenCL
cmake .. -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libOpenCL.so -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include/CL
@9bitbear
Copy link
Author

9bitbear commented Jan 1, 2018

fix for build error:
'CL/cl.h: No such file or directory'

sudo apt-get install opencl-headers

fix for build error:
make[2]: *** No rule to make target '/opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so', needed by 'bin/libxmrstak_opencl_backend.so'. Stop.
fireice-uk/xmr-stak-amd#182

$ cd $AMDAPPSDKROOT/lib/x86_64
$ sudo ln -sf sdk/libOpenCL.so.1 libOpenCL.so

@Daniyal-Javani
Copy link

The xmrig.service link is broken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment