How to – build CUDA-based aionminer on Ubuntu 16.04

This is pretty straight forward and very similar to @MrYukonC’s post detailing the process for Ubuntu 17.10. I had some minor difficulty building in 16.04, so I thought I would also document the process here in case anyone else has similar issues.

First, let’s install the tools we know we will need. If you are starting from Ubuntu mini, you will need g++. I think this is installed by default on other versions of the distro, so you may be able to omit g++ otherwise. It doesn’t hurt to include it - if you already have it installed, apt will just inform you.

sudo apt install g++ git cmake -y

Next, since Ubuntu 16.04 only has Boost v1.58 in the repositories, we will have to download and build boost manually. I used v1.66, but I believe 1.67 is out now and should work as well. Boost is pretty large, so building and installing takes a little while.

wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2
tar --bzip2 -xf boost_1_66_0.tar.bz2
cd boost_1_66_0
./bootstrap.sh
sudo ./b2 install

Next, we’ll need the CUDA toolkit. I used the toolkit downloaded right from nvidia’s website. Here I have the CUDA 9.1 net package installer (small .deb to add package sources to apt). This is a pretty large install, so it takes a while to install as well.

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda -y

Now that the CUDA libraries are installed, it is time to set our PATH and LD_LIBRARY_PATH environment variables so CUDA can be found during compilation.

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64:/usr/local/cuda-9.1/lib64/stubs"
PATH="$PATH:/usr/local/cuda-9.1:/usr/local/cuda-9.1/bin"

Finally, we have all the pre-requisites to build the aion reference miner. So, let’s grab the source and start building.

git clone https://github.com/aionnetwork/aion_miner.git
cd aion_miner
mkdir build && cd build

Here is where you might want to adjust the CMakeLists.txt file if you are having the AVX vs SSE crashing issue described in this thread.

cmake ../aion_reference_miner

At this point, I consistently get the following error:

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find CUDA (missing: CUDA_CUDART_LIBRARY) (found version “9.1”)

This really makes no sense to me, since the error message even says that it found version “9.1”. Regardless, you cannot continue in an error state, so we have to remedy this! Now, I’m not a regular cmake user, so I am not sure the cause of this error or the correct way to fix it, but the easiest way I know of is to simply override the CMakeCache.txt file that is in the build directory. So, we’ll use nano and modify the CMakeCache.txt file

nano CMakeCache.txt

From here, you can either go to line 233, or use CTRL+W and search for CUDART, which is the missing reference. You’ll notice that the file says CUDA_CUDART_LIBRARY:FILEPATH=CUDA_CUDART_LIBRARY-NOTFOUND, and we will simply update this with the correct path.

//“cudart” library
CUDA_CUDART_LIBRARY:FILEPATH=/usr/local/cuda-9.1/targets/x86_64-linux/lib/libcudart.so

Now use CTRL+O to write the file out, and CTRL+X to exit nano. Now just repeat the ‘cmake …/aion_reference_minor’ command and you should have a successful cmake stage:

– Boost version: 1.66.0
– Found the following Boost libraries:
– system
– log_setup
– log
– date_time
– filesystem
– thread
CUDA FOUND
– CUDA_NVCC_FLAGS: --disable-warnings;–ptxas-options=-v;-use_fast_math;-lineinfo;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70
– Configuring done
– Generating done

Now just run make and you should get a complete and functioning executable.

make

Running the miner with -ci should now show your CUDA devices.

2:~/test$ ./aionminer -ci

    ============================= aion reference miner======================
                    Equihash<210,9> CPU&GPU Miner for AION v0.1.8
                    Base on NiceHash equihash miner.
    ============================= aion reference miner======================

Number of CUDA devices found: 6
#0 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28
#1 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28
#2 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28
#3 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28
#4 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28
#5 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28

12 Likes

Nice rundown @closer

*Edit. I used your guide last night. Thank you. I’m curious though, are you able to run the miner from a gui dekstop terminal? I had to switch to a TTY terminal for CUDA to work.

1 Like

Thanks for taking the time to write this tutorial!

1 Like

Thanks for the article. The error you mentioned also can be resolved by using this command:
cmake ../aion_reference_miner -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so

3 Likes

Hey, Thanks for the guide…

I’m pretty sure I followed the instructions on the github page / your guide correctly but I’m getting the following error…

[email protected]:~/aion_miner$ ./aionminer -ci

============================= aion reference miner======================
		Equihash<210,9> CPU&GPU Miner for AION v0.1.8
		Base on NiceHash equihash miner.
============================= aion reference miner======================

terminate called after throwing an instance of ‘std::runtime_error’
what(): CUDA error ‘unknown error’ in func ‘getcount’ line 34
Aborted (core dumped)

Thoughts?

1 Like

Have you tried running the pre-built v0.1.9 CUDA miner? I am curious if you get the same crash.

Do you have an nVidia CUDA device on the machine? Do you have a recent (387+ I believe) nVidia driver installed?

(Just trying to get the basics out of the way)

Also, do you get the same problem when building v0.1.9 (currently in the repository)?

In terms of the Nvidia driver, would this be something that I would do outside of the steps provided in the guide? If so… I did not do that and am not sure how to do that on Ubuntu

Ohh and I tried the v0.0.9 miner which also fails at the same place. Also another quick question… any particular reason I would build the miner if a prebuilt one is up now (I realize it’s been up for a a week or two now)?

First, no reason to build it if the pre-built miner works for you. You’d only need to build it if you had some issue that required different compile options / modifications. Since 0.1.9 dies at the same place, I bet it is simply that you are missing the nvidia driver.

Yes, that is outside the scope of the guide.

If you are on Ubuntu 16.04, you will need to install the nVidia driver manually, as the ones packaged with Ubuntu are not new enough to support the required CUDA version. If you installed the nvidia driver from the restricted drivers manager within ubuntu, then you will need to remove those and update manually to the latest (16.04’s nvidia driver is too old and doesn’t support the correct cuda version).

Head here (nvidia’s driver search page) and follow their instructions. The only real trick is that you have to shutdown any display manager you have running in order to install the driver. This also has a tendency to screw with your X settings, so if you are using X then this is where things can get squirrelly.

Basically the process is to

  1. Download the driver
  2. Log into a console (control + alt + F1, for instance)
  3. Shutdown your display manager (sudo systemctl stop lightdm, for instance)
  4. Make the driver package runnable (chmod +x NVIDIA....run)
  5. Then, run the driver package (sudo ./NVIDIA....run)
  6. Follow the prompts, let it replace your xorg.conf, and then you can restart X (sudo systemctl start lightdm)
    (You may need to reboot here)

If all goes well, you should be back at your login prompt where you can log in and everything is working. And with a working driver, the cuda call to look for devices shouldn’t return an error (assuming you have a cuda device on the machine).

If all doesn’t go well, you’ll have to google a bit to see what it is complaining about. First bet is that nouveau is conflicting with the nvidia install, so you will have to get rid of that (if this happens, sudo apt --purge nouveau should do the trick). If it is something else… well, good luck with that. It’s unfortunate that 16.04 doesn’t have up-to-date drivers.

Post back your success.

3 Likes

I followed the instructions from YoukonC. And got the same problem. I was working on this. Looking forward to see the solution.

to save time compiling from sources. is there pre-built aion miners (pool, cpu and gpu) somewhere ?
I followed the URL links on AION wiki downloaded CPU and GPU miners but can’t find pre-built binaries. The tar file appears to be DATA files of sort

Right here.

they are NOT PRE-COMPLIED binaries,
OK no problem I compile from source then

I’m confused - this and this are precompiled binaries. Just untar them and run them. They are on the page I linked.

In fact I just redownloaded and verified. Perhaps you are having problems untarring?

tar --bzip2 -xvf aionminer_CUDA.tar.bz2

ops … this morning I was at work on window 7 box. download the pre-built miners unzip it using 7-z. . forgot it is TAR.

using Ubuntu box at home unzip with TAR … everything is fine now
thanks a lot

Success!!! At least I think…

I now get

[email protected]:~/Desktop$ ./aionminer -ci

============================= aion reference miner======================
		Equihash<210,9> CPU&GPU Miner for AION v0.1.9
		Base on NiceHash equihash miner.
============================= aion reference miner======================

Number of CUDA devices found: 1
#0 GeForce GTX 1080 Ti | SM version: 6.1 | SM count: 28

which I think is what I’m supposed to get…

FYI: If anyone runs into display issues after the install and a login loop, I suggest taking a look at

Welp, off to connect the rest of the GPUs!

That’s a nice link. Which of the methods described was successful for you? When this happened to me in the past I had to purge CUDA…

For me, after getting the login loop, I launched cntrl + alt + f1

Then ran the suggested,

sudo ubuntu-drivers list

sudo ubuntu-drivers autoinstall

and then I restarted lightdm with

sudo service lightdm restart

Then, I restarted my computer which got rid of the login loop as well as the horrendously low resolution and was able to run the aionminer file

This is GREAT – thank you for so many insightful posts. The one prior to this (regarding getting the solo pool properly up and running, and testing the aion reference miner) was incredibly helpful.

I unfortunately had the same issue where I’m missing the nvidia driver.

Following your process-- all looks good until I get to the install (within console). I get a “test script failed” alert, and am asked if I want to continue. Obviously can’t continue… looking online, it appears that this commonly conflicts with nouveau

Found lots of remedies to remove the conflict (https://askubuntu.com/questions/112302/how-do-i-disable-the-nouveau-kernel-driver), but they all require root and I don’t have it.

Sudoedit simply won’t hack it, and I’m not seeing any other ways to get around the issue. Any potential thoughts?

Thank you in advance!

If you don’t have root access, you shouldn’t be able to install the driver at all.

As for the test script failure, you can continue past that. I don’t know why it always fails on ubuntu 16.04, but I’ve installed the driver probably 30 times at this point on ubuntu 16.04 systems and the test script always fails. That being said, I have been successful getting the driver installed anyway, by just ignoring that failure and continuing on.

My understanding is that the test script is something supplied by the OS that the driver installer executes. So, the failure is actually in a script provided by canonical, not nvidia. My recommendation is to ignore the failure and install the driver anyway.

Yes, nouveau is a pain to remove. I still recommend the old sudo apt --purge nvidia* which will rid the system of nouveau also. Then you can cleanly install the binary driver. Before you do that, however, you do have to make sure that the nouveau driver isn’t loaded by the kernel. Let the nvidia installer blacklist nouveau for you, reboot, and then modpobe nouvaeu out first, and you should be able to install the nvidia driver. All of this requies root privilege.

fascinating. Hugely helpful-- thank you so much for the prompt response. This all makes sense – I’m going to proceed ahead with the installation, however I’m seeing there’s “an incomplete installation of libglvnd” – should I allow the installation to overwrite this one?