Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 932781 - x11-drivers/nvidia-drivers add USE=initramfs
Summary: x11-drivers/nvidia-drivers add USE=initramfs
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Ionen Wolkens
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-26 09:53 UTC by Robin Smith
Modified: 2024-05-27 05:12 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Smith 2024-05-26 09:53:15 UTC
Early loading of modules (nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm) is necessary on my laptop.
Comment 1 Ionen Wolkens gentoo-dev 2024-05-26 10:31:08 UTC
(In reply to Robin Smith from comment #0)
> Early loading of modules (nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm) is
> necessary on my laptop.
That sound kind of odd, why would you need to load graphic drivers before mounting filesystems to be able to read these from the disk? Shouldn't be the job of the initramfs to prepare the graphic stack.

And early boot messages can be displayed by several other means than the new and experimental fbdev=1 on nvidia-drm (fbdev=1 also has the capability to unload a previously used DRM device like simpledrm or even nouveau, it is designed to be used late).

*If* I were to add it, I would likely add it masked though. I don't like the idea of people enabling this on a whim and ending up with easily mismatched nvidia versions (loaded from initramfs).

...not to mention that it'll make the initramfs rather big and could come as a bad surprise for those with a small /boot (modules + gsp firmwares add up to ~122MB, or ~74MB if xz compressed).
Comment 2 Robin Smith 2024-05-26 12:27:30 UTC
(In reply to Ionen Wolkens from comment #1)
> (In reply to Robin Smith from comment #0)
> > Early loading of modules (nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm) is
> > necessary on my laptop.
> That sound kind of odd, why would you need to load graphic drivers before
> mounting filesystems to be able to read these from the disk? Shouldn't be
> the job of the initramfs to prepare the graphic stack.
> 
> And early boot messages can be displayed by several other means than the new
> and experimental fbdev=1 on nvidia-drm (fbdev=1 also has the capability to
> unload a previously used DRM device like simpledrm or even nouveau, it is
> designed to be used late).
> 
> *If* I were to add it, I would likely add it masked though. I don't like the
> idea of people enabling this on a whim and ending up with easily mismatched
> nvidia versions (loaded from initramfs).
> 
> ...not to mention that it'll make the initramfs rather big and could come as
> a bad surprise for those with a small /boot (modules + gsp firmwares add up
> to ~122MB, or ~74MB if xz compressed).

Dear dev, apologies for the unclear. I am using a hybrid card laptop with both an integrated Intel card and an Nvidia card. I use prime render offload, primarily relying on the Intel card, and prefix applications with 'prime-run' when I want to use the Nvidia drivers. The issue exists when I don't use initramfs, commands such as 'prime-run glxinfo' and 'nvidia-smi' will fail. I am uncertain if this is the only solution to solve the problem. I have got the idea from Arch Wiki NVIDIA#Early_loading section.
Comment 3 Ionen Wolkens gentoo-dev 2024-05-26 14:26:02 UTC
We have a lot of users with such a laptop that does offloading and it's the first time I hear of someone needing to add the modules to the initramfs for it to work (if anything, it typically just works without needing to configure anything nowadays, not that I have hardware to test myself).

Arch wiki seems to talk about ensuring it gets loaded before the display manager, and it does not need to be on an initramfs to accomplish that. Normally it should get auto-loaded but if for some reason it doesn't you could always make openrc or systemd load it before.

Haven't tested these in a while, but you can create .conf files in /etc/modules-load.d for that, e.g. to load just 'nvidia' you can:

   echo nvidia > /etc/modules-load.d/nvidia.conf

(create the directory if it's missing, openrc should already have "modules" in the boot runlevel and that happens long before display-manager -- similar for systemd)
Comment 4 Robin Smith 2024-05-27 03:12:26 UTC
Seems like no luck with both taking no action and using modules-load.d.

❯ cat /etc/modules-load.d/nvidia.conf
nvidia

❯ lsmod | grep nvidia
nvidia_drm            102400  2
nvidia_modeset       1552384  4 nvidia_drm
i2c_nvidia_gpu         12288  0
nvidia              59686912  28 nvidia_modeset
video                  69632  2 i915,nvidia_modeset

❯ prime-run glxinfo | grep vendor
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51

❯ nvidia-smi
Failed to initialize NVML: Insufficient Permissions
Comment 5 Ionen Wolkens gentoo-dev 2024-05-27 03:41:40 UTC
Did you actually try initramfs and meant that it worked? Or just thought that it "may" help?

That error sounds more like you don't need any of this and just didn't add your user to the video group.
Comment 6 Ionen Wolkens gentoo-dev 2024-05-27 03:45:51 UTC
(In reply to Ionen Wolkens from comment #5)
> Did you actually try initramfs and meant that it worked? Or just thought
> that it "may" help?
> 
> That error sounds more like you don't need any of this and just didn't add
> your user to the video group.
If hadn't done it, for the record this step is mentioned in the gentoo installation handbook, nvidia's README.gentoo, and also on the nvidia-drivers wiki page.

gpasswd -a youruser video
Comment 7 Robin Smith 2024-05-27 04:45:41 UTC
(In reply to Ionen Wolkens from comment #6)
> (In reply to Ionen Wolkens from comment #5)
> > Did you actually try initramfs and meant that it worked? Or just thought
> > that it "may" help?
> > 
> > That error sounds more like you don't need any of this and just didn't add
> > your user to the video group.
> If hadn't done it, for the record this step is mentioned in the gentoo
> installation handbook, nvidia's README.gentoo, and also on the
> nvidia-drivers wiki page.
> 
> gpasswd -a youruser video

Dear dev, thank you for your time and kind help. I did missed adding the video group, after adding it, everything is now working fine. Previously, I configured dracut with `add_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "`, and this method helped me achieve success. However, I now agree that the initramfs is totally not needed. Thank you again for your kind help.
Comment 8 Ionen Wolkens gentoo-dev 2024-05-27 05:12:42 UTC
Oh I see, I suspect that the reason initramfs helped is because it does not include "/etc/modprobe.d/nvidia.conf" alongside the modules, without it all users gain access to your nvidia card and is a security risk.

Good to hear it was that simple then.

May want to cleanup the modules-load.d files if you still have them (not to be confused with the modprobe.d one, keep that one).