Not able to use the second NVIDIA GPU

Fedora 39 here. My Lenovo laptop has two GPU:

gremo@laptop-fedora:~$ lspci -n -n -k | grep -A 2 -e VGA -e 3D
00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] [8086:46a6] (rev 0c)
	Subsystem: Lenovo Device [17aa:3aed]
	Kernel driver in use: i915
--
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104M [GeForce RTX 3070 Mobile / Max-Q] [10de:24dd] (rev a1)
	Subsystem: Lenovo Device [17aa:3833]
	Kernel driver in use: nvidia

I’ve installed the nvidia driver from rpm fusion, latest stable version (535.129):

gremo@laptop-fedora:~$ modinfo -F version nvidia
535.129.03

The problem is that Optimus/Prime isn’t working. switcherooctl show only one GPU. And, worst, the NVIDIA gpu is driving the HDMI output, so basically my external monitor doesn’t work.

gremo@laptop-fedora:~$ switcherooctl list
Device: 0
  Name:        Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics]
  Default:     yes
  Environment: DRI_PRIME=pci-0000_00_02_0
gremo@laptop-fedora:~$ uname -r
6.6.4-200.fc39.x86_64

Any help is much appreciated. I love Fedora and I don’t want to switch to another distro because of this!

Hello @gremo ,
Welcome to :fedora: !
You may have to select the Nvidia as primary display in your BIOS first, and then also there will be probably kernel arguments to pass to blacklist the nuveou drivers. Also there are some discussions about extended monitor connected to laptop around here, in particular there is some I have read about the setup you have Intel integrated with nvidia gpu as extra. You shoud do a search for external monitor +nvidia [edit] the posts were recent in ask.fp.o

Well I’m sorry but what you are saying is not 100% right:

  • In the BIOS, “hybrid” mode should be selected. Otherwise, you end up using only one video card at time. Hybrbid mode means “Optimus” or “Prime”.
  • About the kernel argument, they are added with the nvidia drivers from rmp fusion. /etc/default/grub blacklists nuveou already.

Thanks for helping anyways!

Have you disabled secureboot in the bios?
The output of mokutil --sb-state should confirm this.

What is the output of lsmod | grep nvidia?
If that shows several lines of modules listed then the nvidia drivers are properly loading. If it returns nothing then the nvidia drivers are not loading.

What is the output of dnf list installed \*nvidia\* ?
This will show exactly which nvidia packages are installed. The output should look something like

$ dnf list installed *nvidia*
Installed Packages
akmod-nvidia.x86_64                                                3:535.129.03-1.fc39                            @rpmfusion-nonfree
kmod-nvidia-6.6.3-200.fc39.x86_64.x86_64                           3:535.129.03-1.fc39                            @@commandline     
kmod-nvidia-6.6.4-200.fc39.x86_64.x86_64                           3:535.129.03-1.fc39                            @@commandline     
nvidia-gpu-firmware.noarch                                         20231111-1.fc39                                @updates-testing  
nvidia-persistenced.x86_64                                         3:535.129.03-1.fc39                            @rpmfusion-nonfree
nvidia-settings.x86_64                                             3:535.129.03-1.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia.x86_64                                         3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-cuda.x86_64                                    3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-cuda-libs.i686                                 3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-cuda-libs.x86_64                               3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-kmodsrc.x86_64                                 3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-libs.i686                                      3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-libs.x86_64                                    3:535.129.03-2.fc39                            @rpmfusion-nonfree
xorg-x11-drv-nvidia-power.x86_64                                   3:535.129.03-2.fc39                            @rpmfusion-nonfree

What is the output of nvidia-smi?
If it shows the nvidia card then not only are the drivers loading but the card appears to be functioning. In that case something else is preventing use.

It is possible that an early reboot after installing the drivers may have caused corruption in the actual modules so they are do not function properly.

If everything else seems correct the modules may be rebuilt and reinstalled with 2 steps.

  1. sudo dnf remove kmod-nvidia-$(uname -r) to remove the current modules for the currently running kernel.
  2. sudo akmods --force to rebuild and reinstall that package.
  3. reboot
1 Like

Sorry about that, but you know your BIOS better than I.

Secure boot is disabled indeed:

gremo@laptop-fedora:~$ mokutil --sb-state 
SecureBoot disabled

And it seems nvidia drivers are loaded correctly:

gremo@laptop-fedora:~$ lsmod | grep nvidia
nvidia_drm             94208  0
nvidia_modeset       1556480  1 nvidia_drm
nvidia_uvm           3514368  0
nvidia              62758912  68 nvidia_uvm,nvidia_modeset
nvidia_wmi_ec_backlight    12288  0
video                  77824  4 nvidia_wmi_ec_backlight,ideapad_laptop,i915,nvidia_modeset
wmi                    45056  4 video,nvidia_wmi_ec_backlight,wmi_bmof,ideapad_laptop

Here is the list of installed packages:

gremo@laptop-fedora:~$ dnf list installed \*nvidia\*
Installed Packages
kmod-nvidia-6.6.4-200.fc39.x86_64.x86_64                                                3:535.129.03-1.fc39                                                 @@commandline
nvidia-gpu-firmware.noarch                                                              20231111-1.fc39                                                     @updates

Actually nvidia-smi command is not present in my system.

I’ve also tested the command to rebuild kernel modules, and I did. After reboot, nothing has changed, switcherooctl list only show the Intel graphic card.

Any help is much appreciated. I don’t want to leave Fedora for another distro because of this problem, but I really need to use the monitor wired to the Nvidia GPU card (I don’t need acceleration, no play games… just work with my laptop).

The problem is that only the kmod-nvidia package is installed. There are many other parts which are required.
Installing the nvidia drivers properly required a different path.

  1. sudo dnf remove kmod-nvidia-\*
  2. sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda
  3. wait at least 5 minutes after step 2 completes then reboot. After this the lsmod should look almost exactly the same and there should be many more files in the dnf list command output.

Once this is done the external gpu should work properly. If not then let us know the new conditions.

Note:
I just did a dnf upgrade --refresh and a newer version of the linux-firmware package was installed among almost 250 packages upgraded. I would also suggest you do a full upgrade the same way.

Thanks, I’ll try that. But I’m on Wayland, I don’t know why I need to install cuda package (if I don’t even need video acceleration). I’ll report back!

Then don’t!
it is certainly your choice.

I tend to always suggest that to cover all possibilities and the cuda libs are installed by default anyway.

The fact you are using wayland is immaterial to having the proper drivers for the hardware and the graphics packages to manage the desktop.

Out of curiosity have you read through, It is in by default and should be working, at worst case maybe go down to a previous driver from 535.129.03 .

https://rpmfusion.org/Howto/Optimus

NVIDIA PrimaryGPU Support

Using PrimaryGPU allows to use the NVIDIA driver by default instead of the iGPU. This is also required in order to use external display when internally connected from the NVIDIA hardware. Unfortunately, setting this option automatically when an external display is connected is not supported by NVIDIA at this time. To recover this previous behaviour, you can use:

@gremo Can you report back, i am interested in your findings.

I did the complete driver install as you suggested. I really want to solve this problem but it seems impossibile. Everything is working fine… just, only 1 GPU is listed:

gremo@laptop-fedora:~$ dnf list installed \*nvidia\*
Installed Packages
akmod-nvidia.x86_64                            3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
kmod-nvidia-6.6.6-200.fc39.x86_64.x86_64       3:545.29.06-1.fc39        @@commandline                   
kmod-nvidia-6.6.7-200.fc39.x86_64.x86_64       3:545.29.06-1.fc39        @@commandline                   
nvidia-gpu-firmware.noarch                     20231211-1.fc39           @updates                        
nvidia-modprobe.x86_64                         3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
nvidia-persistenced.x86_64                     3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
nvidia-settings.x86_64                         3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia.x86_64                     3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia-cuda.x86_64                3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia-cuda-libs.x86_64           3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia-kmodsrc.x86_64             3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia-libs.x86_64                3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver
xorg-x11-drv-nvidia-power.x86_64               3:545.29.06-1.fc39        @rpmfusion-nonfree-nvidia-driver

I do not understand the concern. You said you are using a laptop and that it has an nvidia gpu. This means that there are probably an intel iGPU and an nvidia dGPU. The nvidia tools will only show the nvidia gpu though why switcherooctl does not show the second one is interesting.

When did you last reboot? I see the 6.6.7 kernel module for nvidia so you must have updated in the fairly recent past. It appears that if a user does not wait long enough after upgrading a kernel or the nvidia drivers that even though that package may appear to have been installed properly the content may be corrupt. Just for good practice I often suggest that a user manually rebuild the nvidia drivers for insurance.

  1. sudo dnf remove kmod-nvidia-\* to remove old driver packages
  2. sudo akmods --force to rebuild the drivers and reinstall the kmod-nvidia package.
  3. Wait until about 1 minute after step 2 completes then reboot. This often fixes the problem if it was caused by a too early reboot.

Please post the output of inxi -Fzxx so we can see the complete details of what the system actually sees and configures. You may need to install inxi.

You can also have posted the output of the nvidia-smi command by copy & paste exactly as you did with the dnf command below that image.

The fact that smi shows 0% usage of the nvidia is related to the fact that optimus machines are designed to use the iGPU by default and only use the more power demanding dGPU when the user asks for that at the time they launch an app.

It may be that rebuilding the driver and rebooting to load the new driver will solve the issue with switcherooctl.

I have no concerns, only the one related to the fact that switcherooctl doesn’t list both GPU but only the Intel one. I repeat myself: in my laptop, the type-c ouput is currently wired to the NVIDIA card. That is, my type-c monitor won’t work at all. The HDMI, on the other hand, is wired to the Intel GPU and it’s working fine.

As a proof, I can select “Use discrete graphic card only” from the BIOS (insted of “Use hybrid graphic”. The switcherooctl only show the NVIDIA card, my type-c monitor works fine but the HDMI monitor won’t.

I just want to be able to use both card and both outputs. Seems a quite common task indeed.

Back to the topic:

  • I’m using the new 6.6.7 kernel and I’ve rebooted a couple of time 1 hour ago, after installing the complete drivers as you suggested
  • I didn’t posted the raw output of nvidia-smi just to capture show the ouput of switcherooctl just before the nvidia-smi one

Here is the output you are asking. Please not that right now I’m using the laptop alone (no external monitors).

gremo@laptop-fedora:~$ inxi -Fzxx
System:
  Kernel: 6.6.7-200.fc39.x86_64 arch: x86_64 bits: 64 compiler: gcc
    v: 2.40-13.fc39 Desktop: GNOME v: 45.2 tk: GTK v: 3.24.38 wm: gnome-shell
    dm: GDM Distro: Fedora release 39 (Thirty Nine)
Machine:
  Type: Laptop System: LENOVO product: 82RF v: Legion 5 Pro 16IAH7H
    serial: <superuser required> Chassis: type: 10 v: Legion 5 Pro 16IAH7H
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0T76461 WIN
    serial: <superuser required> UEFI: LENOVO v: J2CN56WW date: 09/18/2023
Battery:
  ID-1: BAT0 charge: 78.9 Wh (100.0%) condition: 78.9/80.0 Wh (98.6%)
    volts: 17.6 min: 15.4 model: Celxpert L21C4PC1 serial: <filter>
    status: charging
CPU:
  Info: 14-core (6-mt/8-st) model: 12th Gen Intel Core i7-12700H bits: 64
    type: MST AMCP arch: Alder Lake rev: 3 cache: L1: 1.2 MiB L2: 11.5 MiB
    L3: 24 MiB
  Speed (MHz): avg: 442 high: 648 min/max: 400/4600:4700:3500 cores: 1: 400
    2: 400 3: 400 4: 400 5: 644 6: 400 7: 400 8: 400 9: 579 10: 400 11: 648
    12: 400 13: 400 14: 400 15: 400 16: 400 17: 577 18: 400 19: 400 20: 400
    bogomips: 107520
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: Intel Alder Lake-P GT2 [Iris Xe Graphics] vendor: Lenovo
    driver: i915 v: kernel arch: Gen-12.2 ports: active: eDP-1 empty: DP-1,DP-2
    bus-ID: 00:02.0 chip-ID: 8086:46a6
  Device-2: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q] vendor: Lenovo
    driver: nvidia v: 545.29.06 arch: Ampere pcie: speed: 2.5 GT/s lanes: 8
    bus-ID: 01:00.0 chip-ID: 10de:24dd
  Device-3: Chicony [] driver: uvcvideo type: USB rev: 2.0 speed: 480 Mb/s
    lanes: 1 bus-ID: 3-6:4 chip-ID: 04f2:b67d
  Display: wayland server: X.org v: 1.20.14 with: Xwayland v: 23.2.3
    compositor: gnome-shell driver: gpu: i915 display-ID: 0
  Monitor-1: eDP-1 model: BOE Display 0x0a1f res: 2560x1600 dpi: 189
    diag: 406mm (16")
  API: EGL Message: EGL data requires eglinfo. Check --recommends.
Audio:
  Device-1: Intel Alder Lake PCH-P High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 chip-ID: 8086:51c8
  Device-2: NVIDIA GA104 High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel pcie: speed: 2.5 GT/s lanes: 8
    bus-ID: 01:00.1 chip-ID: 10de:228b
  API: ALSA v: k6.6.7-200.fc39.x86_64 status: kernel-api
  Server-1: PipeWire v: 1.0.0 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin
Network:
  Device-1: Intel Alder Lake-P PCH CNVi WiFi driver: iwlwifi v: kernel
    bus-ID: 00:14.3 chip-ID: 8086:51f0
  IF: wlp0s20f3 state: up mac: <filter>
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Lenovo driver: r8169 v: kernel pcie: speed: 2.5 GT/s lanes: 1
    port: 3000 bus-ID: 34:00.0 chip-ID: 10ec:8168
  IF: enp52s0 state: down mac: <filter>
Bluetooth:
  Device-1: Intel AX211 Bluetooth driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 bus-ID: 3-10:7 chip-ID: 8087:0033
  Report: btmgmt ID: hci0 rfk-id: 2 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: <filter> bt-v: 5.3 lmp-v: 12
Drives:
  Local Storage: total: 942.7 GiB used: 176.88 GiB (18.8%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO Plus 500GB
    size: 465.76 GiB speed: 31.6 Gb/s lanes: 4 serial: <filter> temp: 37.9 C
  ID-2: /dev/nvme1n1 vendor: Samsung model: MZVL2512HCJQ-00BL2
    size: 476.94 GiB speed: 63.2 Gb/s lanes: 4 serial: <filter> temp: 43.9 C
Partition:
  ID-1: / size: 464.17 GiB used: 176.69 GiB (38.1%) fs: btrfs
    dev: /dev/nvme0n1p3
  ID-2: /boot size: 973.4 MiB used: 132.7 MiB (13.6%) fs: ext4
    dev: /dev/nvme0n1p2
  ID-3: /boot/efi size: 598.8 MiB used: 63.3 MiB (10.6%) fs: vfat
    dev: /dev/nvme0n1p1
  ID-4: /home size: 464.17 GiB used: 176.69 GiB (38.1%) fs: btrfs
    dev: /dev/nvme0n1p3
Swap:
  ID-1: swap-1 type: zram size: 8 GiB used: 210.8 MiB (2.6%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 38.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Processes: 942 Uptime: 20m Memory: total: 16 GiB note: est.
  available: 15.35 GiB used: 8.64 GiB (56.3%) Init: systemd v: 254
  target: graphical (5) default: graphical Compilers: gcc: 13.2.1 Packages:
  pm: rpm pkgs: N/A note: see --rpm pm: flatpak pkgs: 106 Shell: Bash
  v: 5.2.21 running-in: kgx inxi: 3.3.31

Sorry for the misunderstanding.
It seems that you may be in a situation where the hardware config is preventing use of both devices or rather both usb-c and internal and hdmi external monitors at the same time.

I have not dealt with a machine configured like yours in the past.

I have seen optimus machines that had the dGPU dedicated to the external port (hdmi) and the iGPU dedicated to the laptop screen in the default config. which forced the use of 2 GPUs to manage both screens at the same time.

In those cases, and only when using xorg, it was possible to have the dGPU manage output to both screens if one simply copied the /usr/share/X11/xorg.conf.d/nvidia.conf file to /etc/X11/xorg.conf.d/nvidia.conf then log in using the xorg desktop and nvidia was able to access both screens. I have no certainty but this may also work in your situation.

No worries. I’m not the only one with this configuration (Intel + NVIDIA in Optimus mode)… I guess I’ve just to wait for someone that had the same problem, or knows how to solve this problem.

It may, of course, be some kind of incopatibility, VBIOS issue, and so on, by Lenovo. I guess we will never know.

I’ll try a fresh install first, than Debian and see what happen :slight_smile: