Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mining optimisation under Linux

Mining under linux

Disclaimer

I'm in no case responsible for fried hardware, erased software or burning down houses. Make sure your miners are always well cooled.

General recommendation

Though you can easily mix nVidia and AMD in the same rig with Linux, it's recommended to use a different thread for each platform so a Driver crash doesn't bring the whole rig down. It should be noted however, that some mining software have trouble when both architecture are found on the same rig.

nVidia

OS

I recommend using Ubuntu. The advantage is this little PPA over there : https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa that will allow easy installation of latest nVidia drivers.

Driver installation

add-apt-repository ppa:graphics-drivers/ppa
apt-get update
apt-get install -y linux-headers-generic nvidia-387 libcuda1-387 xorg --no-install-recommend

Enabling XORG on all GPU

If you don't enable XORG, you won't be able to use nvidia-settings to overclock your card(s), so yes, and X server is needed.

nvidia-xconfig --enable-all-gpus --coolbits=28 --allow-empty-initial-configuration

Create a systemd service file ( see nvidia-mining.service )

vim /nvidia-mining.service
<read and paste content from mining.service below>

Create your mining start-up script (see start-nvidia-mining.sh)

vim /start-nvidia-mining.sh
<read and paste content from start-nvidia-mining.sh below>
chmod +x /start-nvidia-mining.sh

In the script a value of 100 is used for GPUMemoryTransferRateOffset. The max memory overclock you can achieve depends on your card. Start from 100 and increase slowly to find a safe spot ( running stable for more than 30 minutes ).

Enable the service at start-up

systemctl enable /nvidia-mining.service
systemctl start nvidia-mining

AMD ( Polaris tested, possibly all other cards supported by amdgpu )

Flashing new memory stripes

Not covered, you need a Windows computer with ATI flash. The current linux version doesn't support Polaris cards. I recommend checking https://anorak.tech/ for an up-to-date BIOS and how-to.

OS

I recommend using Ubuntu >= 16.04. To get optimal support for latest AMDs you should download and install a kernel newer than 4.11 : http://kernel.ubuntu.com/~kernel-ppa/mainline/drm-next/current/ .

Drivers

I recommend using the opensource driver included with the kernel. (The PRO driver only supports ubuntu 16.04).

However, you're gonnna need to download the full driver archive from AMD ( http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Driver-for-Linux-Release-Notes.aspx , 17.40 when writting this) to install opencl libraries.

Once downloaded, extract the file and ONLY install the following packages (and depedencies):

  • libopencl1-amdgpu-pro-xxx-amd64.deb
  • opencl-amdgpu-pro-icd-xxx-amd64.deb
  • clinfo-amdgpu-pro-xxx-amd64.deb

Overclocking and undervolting support

https://github.com/OhGodACompany/OhGodATool is a tool that allows both of this. It has been tested with Polaris on 4.15 kernels and does allow undervolting/overclocking via the power-play tables.

Undervolting example

  1. Display the voltage and core clock table :
root@host# ./ohgodatool -i 0 --show-core --show-voltage
DPM state 0:
	VDDC: 750 (voltage table entry 0)
	VDDC offset: 0
	Core clock: 300
DPM state 1:
	VDDC: 65282 (voltage table entry 1)
	VDDC offset: -26
	Core clock: 600
DPM state 2:
	VDDC: 65283 (voltage table entry 2)
	VDDC offset: -26
	Core clock: 900
DPM state 3:
	VDDC: 65284 (voltage table entry 3)
	VDDC offset: -26
	Core clock: 1145
DPM state 4:
	VDDC: 65284 (voltage table entry 4)
	VDDC offset: -26
	Core clock: 1215
DPM state 5:
	VDDC: 65284 (voltage table entry 5)
	VDDC offset: -26
	Core clock: 1250
DPM state 6:
	VDDC: 65284 (voltage table entry 6)
	VDDC offset: -26
	Core clock: 1275
DPM state 7:
	VDDC: 950 (voltage table entry 7)
	VDDC offset: 0
	Core clock: 1300

Voltage state 0: 
	VDD = 750
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 1: 
	VDD = 65282
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 2: 
	VDD = 65283
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 3: 
	VDD = 65284
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 4: 
	VDD = 65284
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 5: 
	VDD = 65284
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 6: 
	VDD = 65284
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 7: 
	VDD = 65284
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 8: 
	VDD = 800
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 9: 
	VDD = 850
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 10: 
	VDD = 900
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 11: 
	VDD = 950
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 12: 
	VDD = 1000
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 13: 
	VDD = 1050
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 14: 
	VDD = 1100
	CACLow = 0
	CACMid = 0
	CACHigh = 0
Voltage state 15: 
	VDD = 1150
	CACLow = 0
	CACMid = 0
	CACHigh = 0
  1. Assign the choosen voltage (here 950mV, so position 11) to the latest core clock (here 7)
./ohgodatool -i 2 --core-state 7 --core-vddc-idx 11
Core state 7 VDDC: 7 -> 11

Overclocking example

  1. List the current memory clock
 ./ohgodatool -i 2 --show-mem
Memory state 0:
	VDDC: 750
	VDDCI: 800
	VDDC GFX offset: 0
	MVDD: 900
	Memory clock: 300
Memory state 1:
	VDDC: 65282
	VDDCI: 850
	VDDC GFX offset: 0
	MVDD: 900
	Memory clock: 1000
Memory state 2:
	VDDC: 65283
	VDDCI: 950
	VDDC GFX offset: 0
	MVDD: 900
	Memory clock: 1800
  1. Change the last clock in the table
root@localhost# ./ohgodatool -i 0 --mem-state 2  --mem-clock 2100
Memory state 2 clock: 1800 -> 2100.

Create a systemd service file ( see amd-mining.service )

vim /amd-mining.service
<read and paste content from amd-mining.service below>

Create your mining start-up script (see start-amd-mining.sh)

vim /start-amd-mining.sh
<read and paste content from start-amd-mining.sh below>
chmod +x /start-amd-mining.sh

Enable the service at start-up

systemctl enable /amd-mining.service
systemctl start amd-mining
[Unit]
Description=AMD Mining service
[Service]
User=root
Group=root
GuessMainPID=no
ExecStart=/start-amd-mining.sh
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
[Unit]
Description=nVidia Mining service
[Service]
User=root
Group=root
GuessMainPID=no
ExecStart=/usr/bin/xinit /start-nvidia-mining.sh
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
#!/bin/bash
export GPU_FORCE_64BIT_PTR=1
export GPU_MAX_HEAP_SIZE=100
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100
# Configure card 0
/srv/ohgodatool/ohgodatool -i 0 --core-state 7 --core-vddc-idx 11 --mem-state 2 --mem-clock 2100 --set-fanspeed 60
# Configure card 1
/srv/ohgodatool/ohgodatool -i 1 --core-state 7 --core-vddc-idx 11 --mem-state 2 --mem-clock 2100 --set-fanspeed 60
# and so on ...
cd /xmrstak-amd
./bin/xmr-stak
#!/bin/bash
export GPU_FORCE_64BIT_PTR=1
export GPU_MAX_HEAP_SIZE=100
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100
# Configure your card fan and memory OC :
# Here a value of 1400 is choosen.
# Start from lower and increase by step of 100
# Let it run for 10 minutes, if no crash -> increment again
/usr/bin/nvidia-settings -c :0 -a "[gpu:0]/GPUFanControlState=1" -a "[gpu:0]/GPUTargetFanSpeed=100" -a "[gpu:0]/GPUMemoryTransferRateOffset[3]=100"
# Repeat for the next GPU :
#/usr/bin/nvidia-settings -c :0 -a "[gpu:1]/GPUFanControlState=1" -a "[gpu:1]/GPUTargetFanSpeed=100" -a "[gpu:1]/GPUMemoryTransferRateOffset[3]=100"
# Launch your miner, here xmr-stak
cd /xmrstak-nvidia
./bin/xmr-stak
@reqshark

This comment has been minimized.

Copy link

@reqshark reqshark commented Jan 29, 2018

well done, sir

:)

@PNixx

This comment has been minimized.

Copy link

@PNixx PNixx commented Jun 2, 2018

Has anyone worked with vega 56?

@reqshark

This comment has been minimized.

Copy link

@reqshark reqshark commented Jul 12, 2018

Has anyone worked with vega 56?

@PNixx, yes. Not as cool as rx570 IMO

@vanities

This comment has been minimized.

Copy link

@vanities vanities commented Aug 3, 2018

Thanks!!

@Arman92

This comment has been minimized.

Copy link

@Arman92 Arman92 commented Sep 6, 2018

GREAT! Thank you <3

@mortsavi

This comment has been minimized.

Copy link

@mortsavi mortsavi commented Sep 29, 2018

It makes the claymore to crash... as soon as I set the mem and core. (AMDgpu-pro)

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