Mining with Centos 7 / nvidia GPUs

When comes the choice of the OS, you will face many options.

Windows, Linux, or ‘ready to mine’ OS like pimpos, perfectmine, ethos, simpleming (….) ?

I would say, choose the one you feel the most comfortable with. I wanted a Linux, because I think it’s easier to compile things, and make your own scripts. Also I want to have the full control of it, and for free…

After some research, you will find many tutorials with Ubuntu. I tried It, but never managed to properly install it with the nvidia drivers. The overclock settings were unreachable, whatever I tried. And I tried a lot, uninstalled/reinstalled, used the official drivers, and obviously when you read the forums, there is a lot of similar problems…

So here comes Centos 7, my favorite distro… After a few try, we managed to install it correctly for mining.

All the commands above are executed under root. Juste type ‘su’ and your root password if you are logged in with another user.

Step 1 – Install Centos 7

Download centos 7  (choosed everything iso), from the official website https://www.centos.org/download/ and make USB boot key with Rufus (https://rufus-usb.fr.uptodown.com/windows)

During the install, choose the Desktop Gnome option, and some other packages like ‘development tools’, ‘internet browser’. Important other packages will be installed later.

Step 2 – Update the system

You can either do this with a terminal under Gnome Desktop. I prefer the ssh access, so just a quick install if ever it’s not enabled.

yum install openssh openssh-server openssh-clients openssl-libs

edit the /etc/ssh/sshd_config (for example, change the listen port etc…)

systemctl restart sshd.service
systemctl enable sshd.service

Update the system

yum update -y

Disable selinux, it will avoid a lot of problems after… edit this file, and set it to ‘disabled’

nano /etc/sysconfig/selinux

Install epel repository, it will be useful later

wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -ivh epel-release-latest-7.noarch.rpm

now reboot and check that all is working (and it should, we didn’t do much 🙂 )

Step 3 – Install the nvidia drivers

Download nvidia drivers from nvidia official website (http://www.nvidia.fr/Download/index.aspx), don’t use the one available through yum. People are reporting that they modify the drivers, and it could cause some feature loss, like overclocking. That was one of the main problem we had with Unbuntu. (Choose your card, OS, probably amd64 version, etc, and the download will start)

Download cuda 9.1 toolkit from nvidia official website (https://developer.nvidia.com/cuda-downloads?target_os=Linux). There is an update available, I didn’t install it yet…

Step 4 – Prepare the kernel for the nvidia drivers

Install the kernel-devel and gcc packages. Do all this under ssh or from a console, because we will kill the windows manager.

yum install kernel-devel-$(uname -r) gcc

We need to stop ‘Nouveau’, rebuild the initramfs image and then kill the running desktop manager (gnome).

echo 'blacklist nouveau' >> /etc/modprobe.d/blacklist.conf

dracut /boot/initramfs-$(uname -r).img $(uname -r) --force

systemctl disable gdm

reboot

Once rebooted, the windows manager won’t start and you should be under a terminal. That’s normal don’t panic.

Step 5 – Install the nvidia drivers

Navigate to your Download folder and execute the .run

sh NVIDIA-Linux-x86_64-390.25.run

You will see some licence agreement, say yes to all…. It should run smootly, and the drivers are now installed.

If this completes without an error message then the driver is installed! Congrats!

You can run the xconfig to be sure all is ok.

nvidia-xconfig

re-enable your windows manager, and check it was set as default

systemctl enable gdm

ln -s '/usr/lib/systemd/system/gdm.service' '/etc/systemd/system/display-manager.service'

reboot

If all is working, enable the overclocking options on the gpus:

nvidia-xconfig -a --cool-bits=28 --allow-empty-initial-configuration

reboot again

You now should have X working with the latest nvidia drivers. If you see a black screen, that’s probably ok. You can either check to plug your screen on one of the gpu card, or run the following command.

ps auxw | grep X

you should see the /usr/bin/X process running. And that’s fine. You don’t need to manage all from gnome. X thinks all is working with many screens (one per GPU), and that’s all what we need, as long as we access the system through ssh or a console. Also keep in mind that X will take resources from your cards, and you will loose some hash/s

Step 6 – Install Cuda 9

Navigate to your download folder and run the installer. We tell to override all, not install the nvidia again, and just the toolkit.

sh cuda_9.1.85_387.26_linux.run -override -silent -toolkit

Add the libraries to your system, or you won’t be able to compile the miners.

edit the ld.so.conf, and add the path to cude at the end of the file:

nano /etc/ld.so.conf

add this line: /usr/local/cuda-9.1/lib64 at the end of the file

and run

ldconfig

Step 7 – Check

From there, you can reboot just to be sure all is correctly installed and running. Once logged in, you can check that you can see all your cards:

nvidia-smi

It will list your cards, and the process associated to each card:

ex:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.25 Driver Version: 390.25 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1070 On | 00000000:01:00.0 Off | N/A |
| 19% 57C P2 90W / 110W | 627MiB / 8119MiB | 100% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 1070 On | 00000000:02:00.0 Off | N/A |
| 32% 62C P2 98W / 110W | 613MiB / 8119MiB | 99% Default |

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1589 G /usr/bin/X 8MiB |
| 0 1744 G /usr/bin/gnome-shell 11MiB |
| 0 1932 C /home/rig/mining/ewbf-miner/miner 595MiB |
| 1 1589 G /usr/bin/X 5MiB |
| 1 1932 C /home/rig/mining/ewbf-miner/miner 595MiB |

Step 8 – Overclock

Power limit

Enable the persitant mode, and set 100W as max power, on the card 0 and 1 (settings depends on your card!)

nvidia-smi -pm 1
#gpu 0
nvidia-smi -i 0 -pl 100
#gpu 1
nvidia-smi -i 1 -pl 100

repeat the last line for each card and check with nvidia-smi.

Fan speed

You may want to set yourself the fan speed of each GPU:

#gpu 0
nvidia-settings -a :0 '[gpu:0]/GPUFanControlState=1'
nvidia-settings -a :0 '[fan:0]/GPUTargetFanSpeed=50'

#gpu 1
nvidia-settings -a :0 '[gpu:1]/GPUFanControlState=1'
nvidia-settings -a :0 '[fan:1]/GPUTargetFanSpeed=50'

set GPUFanControlState=0 to switch back to automatic. Setting the fan speed for one card is a good way to see physically where is the card on your rig.

GraphicsClock & MemoryTransferRate Offset

As usual, you need to repeat this for each card, so for the card 0 it is:

nvidia-settings -c :0 -a '[gpu:0]/GPUGraphicsClockOffset[3]=50'
nvidia-settings -c :0 -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=500'

Increase all the settings slowly, step by step. Find the good ratio between power limit, and overclock settings. Don’t apply the same settings for all of the algorythm.

I like to check the cards temperature with this nvidia-smi wrapper: gpustat

yum install python-devel
yum install python-pip
pip install --upgrade pip
pip install gpustat

gpustat -cP

That’s all, now time to download and build some miners (in another post 😉 )

You May Also Like

About the Author: lezard

Crypto addict. Developer. Net & Sys admin.

Leave a Reply

Your email address will not be published. Required fields are marked *