NVIDIA drivers on Intel Nuc

Hi, im using a Zotac mini gaming computer with an Intel Nuc OS. It comes with a geforce 1060 and I’m trying to install the NVIDIA drivers but cant get it to install because its looking for the kernel source path.

Any ideas how to get this to work please?

PS: can correctly see the NVIDIA device with lspci.

Thanks,
Brice

Hi Brice!

You should be able to install the NVIDIA drivers by adding the required packages to your Dockerfile.template, assuming you’re running debian in your container, you could do so by adding:

RUN apt install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//') nvidia-driver

To the Dockerfile.template. That will install the appropriate linux-headers package for the running kernel version, as well as trigger the nvidia driver build using the debian pre-made package which helps to avoid having to deal with further dependencies and scripting.

Let us know how you get on!

@chrischabot thanks! I’m running on ubuntu 16.04 at the moment, assuming that would be the same idea?

Yep same idea, in fact the packages might well be called the same on Ubuntu as that’s Debian based

@chrischabot just tried and that’s the error I get: Unable to locate package linux-headers-standard

So I’ve tried to install the linux-headers-generic and point to the /lib/modules/4.4.0-119-generic/build path when installing the nvidia drivers. It does go through to the next stage to build the kernel module but fails with the error:

ERROR: Unable to load the kernel module 'nvidia.ko'.  This happens most frequently when this kernel module was built against the wrong or improperly
         configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb,
         nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s), or no NVIDIA
         GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

So the thing to keep in mind is that your docker container is running a different distribution then your Host OS is. As such the kernel versions are likely different – which is what likely lead to this error.

When you run uname -a inside of the container OS, the kernel version you get back is the one from the Host OS, I suspect that would be something like 4.9.87.

You can verify that being compiled against the wrong kernel version is indeed causing these issues by looking at the output from dmesg and /var/log/messages – there should be a more detailed error message in there somewhere.

If that is indeed what’s causing this, you can solve that by installing the correct / Host OS linux kernel version matching package, and you should be good to go

thanks for the help, indeed the wrong version,

[1326343.527869] nvidia: version magic '4.4.0-119-generic SMP mod_unload modversions retpoline ' should be '4.12.12-yocto-standard SMP preempt mod_unload '

@chrischabot stupid question, where can I find the headers for 4.12.12-yocto-standard?

@chrischabot found a yocto 4.12.12 kernel at http://git.yoctoproject.org/cgit/cgit.cgi/linux-yocto-4.12/tag/?id=v4.12.12 but not sure if this is exactly what I’m looking for. When trying to build the NVIDIA module it complains that the kernel is not configured and missing version.h.

I think I’m getting closer but still blocked on this one, thanks again for your help.

Hey @brice – Yeah unfortunately it’s not quite that simple, the kernel headers are generated and installed when the kernel is configured and compiled.

What you could try is to install the kernel headers package for 4.12.12 (you might have to look at other Ubuntu versions’ repo to find the right version match) and see if it’ll accept that without matching on the -yocto-standard (I suspect it’ll work but can’t say a 100%).

If that fails you could manually edit the version.h and change the version to 4.12.12-yocto-standard there

What you could try is to install the kernel headers package for 4.12.12 (you might have to look at other Ubuntu versions’ repo to find the right version match) and see if it’ll accept that without matching on the -yocto-standard (I suspect it’ll work but can’t say a 100%).

If that fails you could manually edit the version.h and change the version to 4.12.12-yocto-standard there

@chrischabot I’ve installed the 4.12.12-041212-generic headers and tried the install again. It complained about the gcc version not being the same:

The kernel was built with gcc version 7.2.0 (Ubuntu 7.2.0-3ubuntu1) , but the current compiler version is cc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609.

I’ve ignore it and continued with the build but still getting the same error:

[82458.116656] nvidia: version magic '4.12.12-041212-generic SMP mod_unload ' should be '4.12.12-yocto-standard SMP preempt mod_unload '

I’ve tried to update the version.h but not sure how to go about it:

#define LINUX_VERSION_CODE 265228
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

Do you know how to change the KERNEL_VERSION to 4.12.12-yocto-standard please?

I’ve seen this repo to build kernel modules: https://github.com/resin-io-playground/kernel-module-build

Found the headers there, https://files.resin.io/images/intel-nuc/2.12.5%2Brev1.dev/kernel_modules_headers.tar.gz

Next step goes through but now complains that scripts/basic/fixdep: not found and the build fails.

UPDATE: After fixing some paths, managed to get it to run and build the drivers :tada:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.30                 Driver Version: 390.30                    |
|-------------------------------+----------------------+----------------------+
| 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 1060    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   48C    P0    27W /  N/A |      0MiB /  6073MiB |      2%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Woot, great work on getting that running!

I was almost close to suggesting to check out the Nouveau drivers as backup if that didn’t work, but glad that’s not needed anymore :slight_smile:

Thanks for your help @chrischabot !

1 Like

Hello @brice. Any chance you can share your findings to this? Bumping up against a similar issue.

@wngr you need to download the kernel headers that match the version of resinOS you are using and place them in the right spot in the filesystem.

## Kernel headers
ENV RESINOS_VERSION=2.12.5%2Brev1.prod
ENV YOCTO_VERSION=4.12.12
RUN wget https://files.resin.io/images/intel-nuc/${RESINOS_VERSION}/kernel_modules_headers.tar.gz
RUN tar -xf kernel_modules_headers.tar.gz && rm -rf kernel_modules_headers.tar.gz
RUN mkdir -p /lib/modules/${YOCTO_VERSION}-yocto-standard
RUN mv ./kernel_modules_headers /lib/modules/${YOCTO_VERSION}-yocto-standard/build
RUN ln -s /lib64/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2

Then go ahead and install the drivers using apt-get.

Thanks @brice for the quick response!

@brice I copy and pasted your code into my Docker.template file, and added an apt-get to “install the drivers”:

apt-get install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//') nvidia-driver

Is that the incorrect command?

[main]      ---> Running in 2a683aaff115
[main]     Reading package lists...
[main]     Building dependency tree...
[main]     Reading state information...
[main]     E: Unable to locate package linux-headers-4.14.11-coreos
[main]     E: Couldn't find any package by glob 'linux-headers-4.14.11-coreos'
[main]     E: Couldn't find any package by regex 'linux-headers-4.14.11-coreos'
[main]     E: Unable to locate package nvidia-driver
[main]     
[main]     Removing intermediate container 2a683aaff115
[main]     The command '/bin/sh -c apt-get install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//') nvidia-driver' returned a non-zero code: 100

Just install the drivers, the linux headers should already be there in the right place if you used my Dockerfile code.

1 Like

@brice

I exactly followed your code on my NUC, but couldn’t install driver?

Here is my Dockerfile.template:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu-python:3.5-xenial-build
ENV RESINOS_VERSION=2.29.0%2Brev1.prod

ENV YOCTO_VERSION=4.12.12
RUN wget https://files.resin.io/images/intel-nuc/${RESINOS_VERSION}/kernel_modules_headers.tar.gz
RUN tar -xf kernel_modules_headers.tar.gz && rm -rf kernel_modules_headers.tar.gz
RUN mkdir -p /lib/modules/${YOCTO_VERSION}-yocto-standard
RUN mv ./kernel_modules_headers /lib/modules/${YOCTO_VERSION}-yocto-standard/build
RUN ln -s /lib64/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2
RUN apt-get install nvidia-driver
CMD [ "sleep", "infinity"]

But I am getting this error: E: Unable to locate package nvidia-driver
Any idea?
Looking forward to your reply soon.

Cheers.