Return to Level1Techs.com

Installing NVidia on Linux (Fail Proof)

Alright man, NVidia is always annoying and on any linux distro you face installing an extra repository to keep NVidia updated but sometimes that repository simply does not work for your device. This happens alot with Maxwell- current generation optimus laptops a ton. Not all laptops are effected but some are.

This is the only fool proof old fashioned one shot method to installing that basically cannot go wrong. I have one such device that particularly likes this better on Fedora (my main distribution). That device is the ASUS ROG STRIX GL502VT-DS74. Not sure why but both the negativo (the best NVidia repository in existence) and RPMFusion (:roll_eyes:) do not like this laptop very well.

So lets do this. This is a device agnostic guide however package naming will generally follow fedora named packages. This being said the build requirements should be similar on other distributions.

A good thing to identify head on is your GPU

Execute the following commands to find out:

lspci |grep -E "VGA|3D"

Here was my output:

[[email protected] ~]$ lspci |grep -E "VGA|3D"
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
01:00.0 3D controller: NVIDIA Corporation GM204M [GeForce GTX 970M] (rev a1)
[[email protected] ~]$ 

Before we move on, I suggest you disabled secure boot. If the system has an inability to do so then refer to NVidia’s section on how to sign the drivers using your distributions key. Refer to your distro specific information on how secure boot signing work. Fedora for example has beautiful documentation. For the purposes of example here are both NVidia docs and Fedora’s docs for reference.

http://download.nvidia.com/XFree86/Linux-x86_64/410.104/README/installdriver.html#modulesigning

https://docs.fedoraproject.org/en-US/Fedora/22/html/System_Administrators_Guide/sect-signing-kernel-modules-for-secure-boot.html

Seriously RTFM. Secure boot is a good thing. I have used it to secure my own laptop and put a password on the EFI. If the password is reset so are the keys and despite full disk encryption as well… that means fedora will not be trusted to boot. I have also set that should keys get reset or SB disabled then Fedora will not boot anyways…

Download and acquire the run files for Linux. If you use CUDA like I do then I have provided the link to acquire it as well. Make sure you are acquiring the run files.

https://www.nvidia.com/Download/Find.aspx?lang=en-us

https://developer.nvidia.com/cuda-downloads

Then make it executable
sudo -i
chmod +x (nvidia run files path)

Now for your system you will want to make sure you are up to date.
<package manager> update

For the rest of the installation the following packages will be needed for NVidia building and compiling. Each distro has their variant. Please install them per the directions of your distro. Often some distros will come with distro specific instructions

For RHEL/CENTOS/Fedora I would advise these packages

  • kernel-devel
  • kernel-headers
  • gcc
  • make
  • dkms
  • acpid
  • libglvnd-glx
  • libglvnd-opengl
  • libglvnd-devel
  • pkgconfig

For Debian you will need to add the non free repos. I will provide the debian sources However you will need to find the sources for Ubuntu and other debian based distributions.

#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN REPOS                    
#------------------------------------------------------------------------------#

deb http://mirrors.syringanetworks.net/debian/ stable main contrib non-free
deb-src http://mirrors.syringanetworks.net/debian/ stable main contrib non-free

deb http://mirrors.syringanetworks.net/debian/ stable-updates main contrib non-free
deb-src http://mirrors.syringanetworks.net/debian/ stable-updates main contrib non-free

deb http://security.debian.org/ stable/updates main
deb-src http://security.debian.org/ stable/updates main

deb http://mirrors.syringanetworks.net/debian/ buster-backports main
deb-src http://mirrors.syringanetworks.net/debian/ buster-backports main

I would run the following commands on a debian based distro after getting the sources:

# Setup proper kernel Build Environments (Most people will need this in some form)
# Install microcode depending on your system architecture
sudo apt install build-essential cmake g++ dkms acpid lshw software-properties-common llvm clang firmware-linux firmware-linux amd64-microcode gcc-multilib 

# Install kernel headers
sudo apt install linux-headers-$(uname -r)

# Build some dependencies
sudo apt build-dep linux

It is essential that even with optimus that you blacklist nouveau. It will cause issues if you do not.

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

Now the next step is append rd.driver.blacklist=nouveau to the end of your grub file. This command may vary from distro to distro but this one is effective.

Add it to the end of

GRUB_CMDLINE_LINUX="****"

Now assuming you have a modern system update the grub2-efi.

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

I remove the nouveau X11 driver just to be really sure though it maybe unnecessary for some.

dnf remove xorg-x11-drv-nouveau

Now some people have excluded package updates for xorg-x11* Do not do this if your going this route. I would update to the latest distro specific xorg-x11 drivers for your system first.

After doing so we need to backup and generate a new initramfs. This is how I do so on any RHEL/Novell based distro. These instructions though on Fedora should work for RHEL, CENTOS, OPENSUSE LEAP, SLES etc

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

Now here is where you need to make sure you have a phone or another computer to follow the rest of the guide. We are going to reboot into System Run Level 3 which is the command line only for the remainder of the steps. When you are ready:

systemctl set-default multi-user.target

Now reboot and login as your user and execute access to su again.
sudo -i

This is where you are going to run the NVidia binaries that you downloaded. Here is an example from my process.

[[email protected] ~]$./home/eayers/NVIDIA-Linux-x86_64-430.26.run

Let us walk through this installation. Answer YES to registering the module sources with DKMS if you do not want to have to redo this every time the kernel upgrades. If you want steam to work then answer YES to NVIDIA’s 32 bit library installation. From here on out the installation should go without issue It will not ask you to backup XORG on any recent distro but if it does I suggest you say yes and if your installing CUDA and the installation above went well do the same for CUDA (instructions self explanatory)
If you do CUDA you must maintain the same driver specified by CUDA

[[email protected] ~]$ ./home/eayers/cuda_10.1.168_418.67_linux.run

Alright cool so that went well. Now reset your run level to level 5 aka the graphical interface by executing:

systemctl set-default graphical.target

and reboot. Now we want video acceleration support for VLC and other things so make sure you install these packages on your system.

  • vdpauinfo
  • libva-vdpau-driver
  • libva-utils

That is basically it your all done. Questions an support will be done below.

2 Likes

RESERVED for UPDATES

1 Like

Hi @Heimdallr,

can you please help me out?

I am following the guide but I get the following install error that has to do with selecting DKMS and using a compiler version that is higher than the one the kernel was compiled with (compiler version check). I think that this is a know issue (https://bugzilla.redhat.com/show_bug.cgi?id=1684833) . Not sure if it has been addressed but I do get these errors. Installing without selecting DKMS does not give me the X NVIDIA Server Settings anywhere in control center.

[[email protected] ~]$ uname -a
Linux localhost.localdomain 5.2.9-200.fc30.x86_64 #1 SMP Fri Aug 16 21:37:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] ~]$ gcc --version
gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)
Copyright © 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[[email protected] ~]$ cat /var/lib/dkms/nvidia/435.21/build/make.log
DKMS make.log for nvidia-435.21 for kernel 5.2.9-200.fc30.x86_64 (x86_64)
Sun 01 Sep 2019 05:35:23 PM EDT
make[1]: Entering directory ‘/usr/src/kernels/5.2.9-200.fc30.x86_64’
SYMLINK /var/lib/dkms/nvidia/435.21/build/nvidia/nv-kernel.o
SYMLINK /var/lib/dkms/nvidia/435.21/build/nvidia-modeset/nv-modeset-kernel.o

Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

gcc version 9.1.1 20190503 (Red Hat 9.1.1-1) (GCC)

does not match the compiler used here:

cc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)
Copyright © 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

The compiler version check can be disabled by setting
the IGNORE_CC_MISMATCH environment variable to “1”.
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.

*** Failed CC version check. Bailing out! ***

make[2]: *** [/var/lib/dkms/nvidia/435.21/build/Kbuild:181: cc_version_check] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [Makefile:1601: module/var/lib/dkms/nvidia/435.21/build] Error 2
make[1]: Leaving directory ‘/usr/src/kernels/5.2.9-200.fc30.x86_64’
make: *** [Makefile:81: modules] Error 2

You have a GCC version mismatch. GCC looks like it updated itself faster than the kernel got built on a newer version of GCC. (Unbelievably common on Fedora)

You have to launch the installer with -no-cc-version-check to proceed. Your version difference is only 9.1.x vs 9.2.x so this should be fine.

Common practice on Fedora is if the GCC and Kernel GCC versions match, hold the Kernel and GCC from updating until the future drivers break it, then pick the correct kernel that has the same GCC version as your current version (no way to tell at the moment, you have to experiment) and if that’s not new enough for the driver, update GCC to the last version in your current point release (so in this case in the 9.1.x series) then update to a matching kernel.

Fedora seriously needs a kernel and GCC picker GUI similar to the Kernel GUI for Manjaro. This is what’s holding back Fedora at the moment.

1 Like

Hmm while this might be the case I’m not convinced that this is the issue. When I finish my even round of golf I’ll take a further look but starting here would be a good place

The higher compiler shouldn’t matter as it’s the case on my system

The log does indeed show a GCC mismatch. The newer drivers were updated for compatibility with the latest kernels so that is not the issue. It’s the GCC mismatch (Which happens so often on Fedora that the “rolling build from source” repo for Fedora Nvidia drivers has to be constantly updated.)

Fedora hates minor version mismatches too, so even if the 9.x.x-1 doesn’t match, it fails to build DKMS.

1 Like

Hmm okay well it’s a simple solution. Typically what I’ll do @kbdaemon when on occasion it really doesn’t like the smatch is I’ll install kernel-vanilla-stable or if you don’t mind getting even more bleeding edge with some risk of stability… kernel-vanilla-mainline.

To get started make a choice between a mainline (always up to date but higher chance of bugs) kernel or a vanilla stable kernel (up to date as far as other distributions are but slightly held back to preserve a modicum of stability)

In any case here is how to do so for mainline

sudo dnf config-manager --set-enabled kernel-vanilla-mainline

sudo dnf update

Before rebooting make sure your proper grub commands are loaded into /etc/default/grub and if they weren’t… do so and then update the grub

I run mainline as a daily driver… no driver nor uptime issues so start here and rerun the installer after booting the latest kernel. From my findings stable is usually the next stable release version of the fedora so your a version ahead but vanilla

The whole point of dkms @FurryJackman is to take care of those mismatches and over come them alongside kernel updates. It’s not inherently fedoras fault as much as it’s the fragmented nature of all software in general. It is true other distributions mitigate it better but that doesn’t make fedora fall from the lime light or need some kind of gui tool

If this doesn’t work I’ll see if I can walk you through the painful but mismatch proof akmod setup and then we will need to get you on a vanilla stable kernel as well so that we can carefully monitor the changes in the kernel versions as akmod does require some baby sitting

Treat Negativo17 and akmod as “rolling driver releases” so you will automatically be pushed to newer drivers all the time.

1 Like

They are stable releases of software based directly on Nvidia upstream. The crazy thing is I think I’ve seen a ton of minor Nvidia updates even on Ubuntu as of late. Not sure nor up to date on what’s going on.

The thing is fjm… the way he is installing it as binary so it’s strange to see it throw a fit. Negative has a good repo for seemless updates I agree… rpm fusion is more buggy … but built to fedora packaging standard so it’s a take your pick deal … But hey free software hoorah! :ok_hand::face_with_monocle::laughing:

It’s interesting though normally I don’t see it have a mismatch fit but typically it’s because I’m a new kernel than my gcc vs a newer gcc to my kernel. Maybe there’s something interesting happening here. I don’t have the time to investigate it in the week though

My way to approach it is to get a known stable driver release .run, then find a compatible Kernel + GCC combo and hold it there. Therefore essentially giving you a long term release by locking in specific kernels an GCCs. That’s how I’ve gotten my Fedora installations stable.

That is another potential solution. All depends on what someone’s end goal is. I like to be on the edge of kernel updates but I also don’t mind fixing the occasional oops… some people strongly dislike fixing the oops. I find it amusing but it doesn’t happen as much as it used to I’d say about once a version of fedora release nowadays… strange how bleeding edge is becoming stable

Hey Fellas, thank you very much!

@FurryJackman I tried that -no-cc-version-check arg and that seems to work for the install but I don’t see the NVIDIA control center for in any DE (i.e., the one you typically find on Windows when you right-click). Is there anything more that needs to be done for that?

The weird thing is that I can bring it up in CLI although I’m not sure about the assertiong failure; that can’t be good.

[email protected] ~]$ nvidia-
nvidia-bug-report.sh nvidia-debugdump nvidia-persistenced nvidia-uninstall
nvidia-cuda-mps-control nvidia-installer nvidia-settings nvidia-xconfig
nvidia-cuda-mps-server nvidia-modprobe nvidia-smi

[[email protected] ~]$ nvidia-settings

(nvidia-settings:2894): GLib-GObject-CRITICAL **: 08:37:18.212: g_object_unref: assertion ‘G_IS_OBJECT (object)’ failed

I am about to go and will not have computer access any time soon but will try again.

1 Like

The nvidia control center is nvidia-settings. This can be ran as root or standard user. You should also see it in your applications menu

On Fedora, there is no .desktop file for Nvidia Settings. You have to manually create one in order to access it from a desktop environment. On Ubuntu, it does make a .desktop file, but on Fedora it doesn’t.

10-4 Did not know that. Well its easy for @kbdeamon to create

Here is the file

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=NVIDIA X Server Settings
Comment=Configure NVIDIA X Server Settings
Exec=__UTILS_PATH__/nvidia-settings
Icon=__PIXMAP_PATH__/nvidia-settings.png
Categories=__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__
# Translations provided by Sun Microsystems
Name[de]=NVIDIA X-Server-Einstellungen
Name[es]=Valores de configuración del servidor NVIDIA X
Name[fr]=Paramètres du serveur X NVIDIA
Name[it]=NVIDIA X Server Settings
Name[ja]=NVIDIA X サーバー設定
Name[ko]=NVIDIA X 서버 설정
Name[pt_BR]=Configurações do NVIDIA X Server
Name[zh_CN]=NVIDIA X 服务器设置
Name[zh_HK]=NVIDIA X 伺服器設定
Name[zh_TW]=NVIDIA X 伺服器設定
Comment[de]=Konfigurieren der NVIDIA X-Server-Einstellungen
Comment[es]=Establezca los valores de configuración del servidor NVIDIA X

Comment[fr]=Configurer les paramètres du serveur X NVIDIA

Comment[it]=Configura NVIDIA X Server Settings

Comment[ja]=NVIDIA X サーバー設定を構成します

Comment[ko]=NVIDIA X 서버 설정 구성

Comment[pt_BR]=Definir &configurações de gerenciamento de usuário...

Comment[zh_CN]=配置 NVIDIA X 服务器设置

Comment[zh_HK]=配置 NVIDIA X 伺服器設定

Comment[zh_TW]=配置 NVIDIA X 伺服器設定

Name[pl]=Ustawienia serwera X NVIDIA

Comment[pl]=Narzędzie konfiguracyjne dla ustawień serwera X NVIDIA

Yea nvidia-settings works from cli but I don’t see it in any menu.

Hi @Heimdallr. Cool, thanks for the file. I added to /usr/share/applications but I am still not seeing the icon in any menu

[[email protected] applications]$ pwd
/usr/share/applications

[[email protected] applications]$ ll nvidia-settings.desktop
-rw-r–r--. 1 root root 1360 Sep 11 10:01 nvidia-settings.desktop

Everything seems to be inline with all other files and I am able to get the menu option in Xfce by editing the file as follows:

[[email protected] applications]# cat nvidia-settings.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=NVIDIA X Server Settings
Comment=Configure NVIDIA X Server Settings
Exec=nvidia-settings
Icon=/usr/share/doc/NVIDIA_GLX-1.0/nvidia-settings.png
Categories=NVIDIA_SETTINGS_DESKTOP_CATEGORIES

Any ideas?

Thats very strange… what desktop environment I might have missed it earlier

Hey uh @sgtawesomesauce Im at a loss on this one. Fedora should normally update his application menu. It didnt.

@kbdeamon if this method doesnt work for you. You may always see if you can fall back on negativo17

Strange. I did not do anything accept for the below and now I see it in GNOME under “Other>NVIDIA X Server Settings” just like Xfce. So now looks right but before I tried the same thing and the stuff below and was only able to get it to work in Xfce. Going to try GNOME now.

I tried GNOME, Xfce and MATE.

I got it to work in Xfce by editing the file as listed below so I suspect that I may be missing something for GNOME and MATE.

[Desktop Entry] Type=Application Encoding=UTF-8 Name=NVIDIA X Server Settings Comment=Configure NVIDIA X Server Settings Exec=nvidia-settings Icon=/usr/share/doc/NVIDIA_GLX-1.0/nvidia-settings.png Categories= **NVIDIA_SETTINGS_DESKTOP_CATEGORIES**

I think that I will try to just create a shortcut of some sort. A link/shortcut should not cause any issues right?

1 Like