FS#65118 - nvidia_layers.json missing from nvidia-utils (breaks prime-run for vulkan)

Attached to Project: Arch Linux
Opened by Scott Mansell (phire) - Saturday, 11 January 2020, 22:30 GMT
Last edited by Giancarlo Razzolini (grazzolini) - Tuesday, 21 January 2020, 01:24 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Giancarlo Razzolini (grazzolini)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Vulkan Prime offload support for Nvidia relies on an implicitly loaded vulkan layer VK_LAYER_NV_optimus, that re-orders and hides physical devices depending on selected GPU.

In the current version of the nvidia-utils (440.44-2), this layer is not installed, so vulkan applications always default to the same GPU, independent of Prime environment variables. In my case, it defaults to integrated graphics.

The fix is simple, /usr/share/vulkan/implicit_layer.d/nvidia_layers.json needs to be included in the nvidia-utils package.

The nvidia-full-beta AUR package already installs this file and works as expected.
This task depends upon

Closed by  Giancarlo Razzolini (grazzolini)
Tuesday, 21 January 2020, 01:24 GMT
Reason for closing:  Implemented
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 12 January 2020, 15:12 GMT
grazzolini, could you verify this part?
Comment by Giancarlo Razzolini (grazzolini) - Monday, 13 January 2020, 13:15 GMT
@Scott

I have prime-run running vulkan applications just fine without this file. Can you paste the output of vulkaninfo both without and with prime-run? Also, do you have vulkan-intel installed?
Comment by Scott Mansell (phire) - Monday, 13 January 2020, 22:25 GMT
By broken, I mean prime-run becomes a no-op which does nothing when nvidia_layers.json is missing.

I have attached four outputs from vulkan info.

The first is `vulkaninfo` without nvidia_layers.json; Notice that both GPUs are available (yes, vulkan-intel is installed)

The second is `prime-run vulkaninfo`. Notice that the output is identical to the previous file, prime-run has done nothing.

The third is `vulkaninfo` with nividia_layers.json; The output is almost identical to the previous outputs, except an extra layer has been loaded.

The fourth is `prime-run vulkaninfo` with nvidia_layers.json; Notice how there is now only one GPU available to pick, the intel GPU has been hidden.

Comment by Giancarlo Razzolini (grazzolini) - Tuesday, 14 January 2020, 01:14 GMT
@Scott,

If you look at prime-run, it already forces only the nvidia card to show up for vuklan applications. It has:

__VK_LAYER_NV_optimus=NVIDIA_only

As per the nvidia official prime render offload documentation, which is used for finer grained control over vulkan. I'm not entirely sure your issue is with prime-run per se, but it can be an issue with your vulkan installation. I can look into adding the nvidia_layers file into the official nvidia-utils package, but let's first make sure your issue is not related to anything else you might have installed.

Uninstall any nvidia package you might have from the AUR, including nvidia-utils-beta and make sure you have neither a /etc/X11/xorg.conf nor any nvidia or intel related /etc/X11/xorg.conf.d snippet. Start your X and paste your full X log. As a comparison with vulkan, paste the output of both glxinfo and prime-run glxinfo. And, please make sure you have no vulkan environment variables, specially VK_ICD_FILENAMES.
Comment by Scott Mansell (phire) - Tuesday, 14 January 2020, 02:07 GMT
I've read the documentation. Yes, prime-run only exports some environment variables.

What's important is whatever code reads those environment variables and acts accordingly. According to Nvidia's documentation (https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html), this control is done by the special "VK_LAYER_NV_optimus" layer.

In my initial testing, I found that the VK_LAYER_NV_optimus layer was simply not loaded, both with and without the __NV_PRIME_RENDER_OFFLOAD=1 and __VK_LAYER_NV_optimus=NVIDIA_only environment set.

I traced who was responsible for loading the VK_LAYER_NV_optimus layer, and was pointed to /usr/share/vulkan/implicit_layer.d/nvidia_layers.json

I've since reverted to the stock nvidia and nvidia-utils packages with just the nvidia_layers.json manually added to my filesystem (the vulkan info results from above were done with the stock nvidia/nvidia-utils package, with and without nvidia_layers.json).

With nvidia_layers.json added, the VK_LAYER_NV_optimus layer is loaded (all the time, independent of any environment variables), and responds to the __VK_LAYER_NV_optimus=NVIDIA_only and __VK_LAYER_NV_optimus=non_NVIDIA_only environment variables as expected.

To satisfy your paranoia, I have verified the lack of vulkan environment variables or any /etc/xorg.conf* modifications (this arch install is just two weeks old) and attached the requested logs.
Comment by Giancarlo Razzolini (grazzolini) - Tuesday, 14 January 2020, 10:58 GMT
I have talked with the nvidia-utils-beta maintainer which, by chance, is also a trusted user. It seems that the nvidia_layers.json was added to the installation of nvidia on 435.17. I will see if we can also add to the nvidia-utils package in the official repositories.

p.s.: The next time I see you telling anyone that is *helping* you for free that they are *paranoid* or being disrespectful with anyone else on the official Arch channels for support, I'll ban you. Consider this a warning. Also, please read the CoC
Comment by Giancarlo Razzolini (grazzolini) - Thursday, 16 January 2020, 13:57 GMT
I'm reworking nvidia-utils to include all files that are mentioned on https://download.nvidia.com/XFree86/Linux-x86_64/440.44/README/installedcomponents.html.
Comment by Sven-Hendrik Haase (Svenstaro) - Thursday, 16 January 2020, 14:21 GMT
Is it also relevant to be added to lib32-nvidia-utils?
Comment by Giancarlo Razzolini (grazzolini) - Thursday, 16 January 2020, 14:24 GMT
If there's a 686 layer file, sure. I'm looking at it right now.
Comment by Giancarlo Razzolini (grazzolini) - Monday, 20 January 2020, 15:47 GMT
@Scott

The nvidia-utils-440.44-3 package adds this layer. Can you please test this on your side and let me know if this works? The package is on [testing].
Comment by Scott Mansell (phire) - Monday, 20 January 2020, 21:51 GMT
I have tested nvidia-utils-440.44-3 and everything is working as expected.

Thanks for fixing this.
Comment by Giancarlo Razzolini (grazzolini) - Tuesday, 21 January 2020, 01:24 GMT
I'm closing this. The package should get out of [testing] in the next few days.

Loading...