Skip to content

Instantly share code, notes, and snippets.

@mmitech
Forked from gboddin/00-MINING.md
Created February 6, 2020 13:11
Show Gist options
  • Save mmitech/2244f5fa1abb241fb0ba55d0001bdbd0 to your computer and use it in GitHub Desktop.
Save mmitech/2244f5fa1abb241fb0ba55d0001bdbd0 to your computer and use it in GitHub Desktop.

Revisions

  1. @gboddin gboddin revised this gist Jan 9, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -65,15 +65,15 @@ Not covered, you need a Windows computer with ATI flash. The current linux versi

    ### OS

    I recommend using Ubuntu. To get optimal support for latest AMDs you should download and install the latest kernel packages from : http://kernel.ubuntu.com/~kernel-ppa/mainline/drm-next/current/ .
    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 ( https://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%E2%80%93Release-Notes.aspx ) to install opencl libraries.
    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 :
    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
  2. @gboddin gboddin revised this gist Dec 30, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -69,9 +69,9 @@ I recommend using Ubuntu. To get optimal support for latest AMDs you should down

    ### Drivers

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

    You will still however need to download the full driver archive over : https://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%E2%80%93Release-Notes.aspx .
    However, you're gonnna need to download the full driver archive from AMD ( https://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%E2%80%93Release-Notes.aspx ) to install opencl libraries.

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

  3. @gboddin gboddin revised this gist Dec 30, 2017. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -67,6 +67,18 @@ Not covered, you need a Windows computer with ATI flash. The current linux versi

    I recommend using Ubuntu. To get optimal support for latest AMDs you should download and install the latest kernel packages from : http://kernel.ubuntu.com/~kernel-ppa/mainline/drm-next/current/ .

    ### Drivers

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

    You will still however need to download the full driver archive over : https://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%E2%80%93Release-Notes.aspx .

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

    - 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.
  4. @gboddin gboddin revised this gist Dec 29, 2017. 2 changed files with 8 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions amd-mining.service
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,10 @@ Group=root

    GuessMainPID=no
    ExecStart=/start-amd-mining.sh
    Restart=always
    RestartSec=30
    StartLimitInterval=200
    StartLimitBurst=5

    [Install]
    WantedBy=multi-user.target
    4 changes: 4 additions & 0 deletions nvidia-mining.service
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,10 @@ 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
  5. @gboddin gboddin revised this gist Dec 29, 2017. 5 changed files with 61 additions and 14 deletions.
    41 changes: 31 additions & 10 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,7 @@ I'm in no case responsible for fried hardware, erased software or burning down h

    ## General recommendation

    Don't mix nVidia and AMD in the same rig. sgminer doesn't play nice, and you might want to use a different distro depending on the hardware.
    More on this later.
    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

    @@ -32,19 +31,19 @@ If you don't enable XORG, you won't be able to use nvidia-settings to overclock
    nvidia-xconfig --enable-all-gpus --coolbits=28 --allow-empty-initial-configuration
    ```

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

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

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

    ```sh
    vim /start-mining.sh
    <read and paste content from start-mining.sh below>
    chmod +x /start-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.
    @@ -54,14 +53,15 @@ Start from 100 and increase slowly to find a safe spot ( running stable for more
    ### Enable the service at start-up

    ```sh
    systemctl enable /mining.service
    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.
    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

    @@ -232,3 +232,24 @@ 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 )

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

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

    ```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

    ```sh
    systemctl enable /amd-mining.service
    systemctl start amd-mining
    ```
    12 changes: 12 additions & 0 deletions amd-mining.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    [Unit]
    Description=AMD Mining service

    [Service]
    User=root
    Group=root

    GuessMainPID=no
    ExecStart=/start-amd-mining.sh

    [Install]
    WantedBy=multi-user.target
    4 changes: 2 additions & 2 deletions mining.service → nvidia-mining.service
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    [Unit]
    Description=Mining service
    Description=nVidia Mining service

    [Service]
    User=root
    Group=root

    GuessMainPID=no
    ExecStart=/usr/bin/xinit /start-mining.sh
    ExecStart=/usr/bin/xinit /start-nvidia-mining.sh

    [Install]
    WantedBy=multi-user.target
    14 changes: 14 additions & 0 deletions start-amd-mining.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/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
    4 changes: 2 additions & 2 deletions start-mining.sh → start-nvidia-mining.sh
    Original file line number Diff line number Diff line change
    @@ -14,5 +14,5 @@ export GPU_SINGLE_ALLOC_PERCENT=100
    #/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
    xterm -geometry 80x40+620+0 -e ./bin/xmr-stak
    cd /xmrstak-nvidia
    ./bin/xmr-stak
  6. @gboddin gboddin revised this gist Dec 29, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -223,6 +223,7 @@ Memory state 2:
    VDDC GFX offset: 0
    MVDD: 900
    Memory clock: 1800
    ````

    2. Change the last clock in the table

  7. @gboddin gboddin revised this gist Dec 29, 2017. 1 changed file with 176 additions and 1 deletion.
    177 changes: 176 additions & 1 deletion 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,179 @@ Start from 100 and increase slowly to find a safe spot ( running stable for more

    ```sh
    systemctl enable /mining.service
    ```
    ```

    ## 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.

    ### OS

    I recommend using Ubuntu. To get optimal support for latest AMDs you should download and install the latest kernel packages from : http://kernel.ubuntu.com/~kernel-ppa/mainline/drm-next/current/ .

    ### 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 :

    ```sh
    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

    ```

    2. Assign the choosen voltage (here 950mV, so position 11) to the latest core clock (here 7)

    ```sh
    ./ohgodatool -i 2 --core-state 7 --core-vddc-idx 11
    Core state 7 VDDC: 7 -> 11
    ```
    #### Overclocking example

    1. List the current memory clock

    ```sh
    ./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

    2. Change the last clock in the table

    ```sh
    root@localhost# ./ohgodatool -i 0 --mem-state 2 --mem-clock 2100
    Memory state 2 clock: 1800 -> 2100.
    ```

  8. @gboddin gboddin revised this gist Nov 15, 2017. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,9 @@ that will allow easy installation of latest nVidia drivers.
    ### Driver installation

    ```sh
    apt-get install nvidia-387 libcuda1-387 xorg --no-install-recommend
    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
    @@ -36,6 +38,7 @@ nvidia-xconfig --enable-all-gpus --coolbits=28 --allow-empty-initial-configurati
    vim /mining.service
    <read and paste content from mining.service below>
    ```

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

    ```sh
    @@ -45,7 +48,8 @@ chmod +x /start-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 )
    Start from 100 and increase slowly to find a safe spot ( running stable for more than 30 minutes ).


    ### Enable the service at start-up

  9. @gboddin gboddin created this gist Nov 15, 2017.
    54 changes: 54 additions & 0 deletions 00-MINING.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    # 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

    Don't mix nVidia and AMD in the same rig. sgminer doesn't play nice, and you might want to use a different distro depending on the hardware.
    More on this later.

    ## 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

    ```sh
    apt-get install 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.

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

    ### Create a systemd service file ( see mining.service )

    ```sh
    vim /mining.service
    <read and paste content from mining.service below>
    ```
    ### Create your mining start-up script (see start-mining.sh)

    ```sh
    vim /start-mining.sh
    <read and paste content from start-mining.sh below>
    chmod +x /start-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

    ```sh
    systemctl enable /mining.service
    ```
    13 changes: 13 additions & 0 deletions mining.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    [Unit]
    Description=Mining service

    [Service]
    User=root
    Group=root

    GuessMainPID=no
    ExecStart=/usr/bin/xinit /start-mining.sh

    [Install]
    WantedBy=multi-user.target

    18 changes: 18 additions & 0 deletions start-mining.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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
    xterm -geometry 80x40+620+0 -e ./bin/xmr-stak