Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked GPU driver installations for x86 systems #6273

Merged
merged 71 commits into from
Apr 1, 2023
Merged

Reworked GPU driver installations for x86 systems #6273

merged 71 commits into from
Apr 1, 2023

Conversation

Fourdee
Copy link
Collaborator

@Fourdee Fourdee commented Mar 25, 2023

Reworked GPU driver installations for x86 systems.

This provides better control of GPU drivers for DietPi, adding support for Vulkan and resolves issues with Steam Proton. Users will be prompted to select a driver package during DietPi-Update.: #6262

Testing:

  • x86 testing only. All these changes are disabled for other Arch's. However, ARM test to check for any conflicts during patch should be done.
  • 🈯 DietPi-Update >> Intel + Steam (Sonic Mania via Proton 7.0-6)
  • 🈯DietPi-Update >> Nvidia + Steam (Sonic Mania via Proton 7.0-6)
  • 🈯DietPi-Update >> Custom
  • 🈯DietPi-Update >> None
  • 🈯 DietPi-Config >> Manual test of all options.

ToDo:
AMD test.
Docs to enable proton (disabled by default):

  • Load Steam
  • Click View
  • Settings
  • SteamPlay
  • Enable Steam Play for all other titles

@Fourdee Fourdee added this to the v8.16 milestone Mar 25, 2023
@Fourdee Fourdee requested a review from MichaIng March 25, 2023 19:13
@Fourdee Fourdee self-assigned this Mar 25, 2023
@MichaIng MichaIng linked an issue Mar 25, 2023 that may be closed by this pull request
dietpi.txt Outdated Show resolved Hide resolved
dietpi/dietpi-config Outdated Show resolved Hide resolved
.update/patches Outdated Show resolved Hide resolved
@MichaIng
Copy link
Owner

Conflict resolved.

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 27, 2023

Was going to try and get this finished today (I have time). But GitHub throws this every time lol.

Screenshot from 2023-03-27 13-29-29

@MichaIng
Copy link
Owner

Indeed GitHub has some troubles currently:

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 28, 2023

@MichaIng
Ok all changes done as far as I can see, thanks for helping out 👍 .
Once I make Shellcheck happy, I will do retesting this week and report back.

Not sure what this means?

In ./dietpi/func/dietpi-set_hardware line 2330:
			[[ "${install_array[@]}" ]] && G_AG_CHECK_INSTALL_PREREQ "${install_array[@]}"
                           ^-------------------^ SC2[19](https://github.com/MichaIng/DietPi/actions/runs/4543358692/jobs/8007940402?pr=6273#step:6:20)9 (error): Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

@MichaIng
Copy link
Owner

MichaIng commented Mar 28, 2023

Awesome! Looks very good, I'll also do some test Steam installs on an old Laptop with Intel GPU. I think it does not support Vulkan, but good for testing the options in general an interesting to see what Steam with Proton does if Vulkan is not supported but the library installed.

Not sure what this means?

${array[@]} adds the array as array, while [[ ... ]] checks strings. So bash internally translates the array into a string with each array entry concatenated. shellcheck prefers things to be done explicitly, so using ${array[*]} which adds the array as concatenated string directly. But actually, when only checking whether an entry exist, it is sufficient to check for the first entry: [[ ${install_array[0]} ]]

@ravenclaw900
Copy link
Collaborator

Just curious, but since computers can have more than 1 GPU (most common would be Intel iGPU and Nvidia dGPU, but any combination of AMD dGPU, AMD iGPU, Intel iGPU, Intel dGPU, and Nvidia dGPU would theoretically be possible), is there a way to install drivers for 2 of them at once? If using this, would it also be possible to use a DietPi script to switch between the active GPU (though with drivers installed Steam at least should be able to decide which one to use)?

@MichaIng
Copy link
Owner

That is indeed not possible anymore with this PR. I think it is a very rare case that one makes actually use of two different GPUs, so didn't bother.

But there may be indeed multi-monitor cases which would benefit from two driver sets when setup properly. I've never worked with such, so no idea if/how applications or X11 would handle this when really two different GPUs are used with their own API libraries and in case own DDX.

Do you think we should preserve this and basically keep the "install/uninstall"-each style menu we had before or make a checkbox menu from it to allow multi-select?

@MichaIng MichaIng changed the title Dev Reworked GPU driver installations for x86 systems Mar 28, 2023
@MichaIng
Copy link
Owner

Conflict resolved.

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 29, 2023

That is indeed not possible anymore with this PR. I think it is a very rare case that one makes actually use of two different GPUs, so didn't bother.

Yep. Although most high end laptops will have 2 GPU's. Onboard GPU (Intel CPU+GPU) and dedicated GPU. However, as I have no access to this hardware, I am unable to impliment and/or test any of it. I also believe they require additional configuration for their use and switching support in DietPi would need to be added as @ravenclaw900 mentioned.

Maybe down the line we could add "Combo" driver stacks and support this with comminuty effort. However, I believe for now, simply getting a single dedicated and functional driver install fully supported in DietPi should be the goal?

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 29, 2023

Retests
Nvidia:

  • Previous DietPi GPU driver installed
  • Patched to Fourdee/dev, selected Nvidia driver
  • 🈯 Steam + Sonic Mania
  • 🈯 vkcube | NB: A reboot after driver install was required before this would work , else Invalid MIT-MAGIC-COOKIE-1 keyCannot find a compatible Vulkan installable client driver (ICD).

Intel:

  • Same test as above
  • Patched to Fourdee/dev, selected Intel driver
  • 🈯 Steam + Sonic Mania
  • 🈯 vkcube | Same as Nvidia, reboot required assuming for X to load support for Vulkan?

General | Manual driver installs, removals, custom etc:

  • 🈯 All driver installs (+none +custom) tested in dietpi-config

@ravenclaw900
Copy link
Collaborator

I have a couple of really old laptops that have Intel + Nvidia and Intel + AMD, and my current desktop has AMD + Nvidia, so I wouldn't call it uncommon to have a lower-power GPU and a dedicated GPU. It looks like there's a built-in way to switch between used GPU, as long as both drivers are installed (https://www.kernel.org/doc/html/latest/gpu/vga-switcheroo.html). I'd be happy to try setting this up in a separate PR.

@MichaIng
Copy link
Owner

I wouldn't call it uncommon to have a lower-power GPU and a dedicated GPU.

That is right, most CPUs (is that right wording in this context, AMD called it APUs...) have an integrated GPU nowadays, also on desktop systems. But if a dedicated GPU is present, I guess it is in very uncommon that the integrated GPU is ever used.

I'd be happy to try setting this up in a separate PR.

Good idea, so we have a simple tested single-stack selection for now and add multi-stack selection once we know how it can generally be used and can then also check whether there are package conflicts between the stacks and how to resolve them best.

Another thing, to not forget it, is that I think some generic FLOSS stack would be nice, so using only Mesa drivers, including Mesa Vulkan and mesa-va-drivers. Shall we add the latter to the AMD stack? Generally AMD supports it. Nvidia btw as well if the FLOSS nouveau driver is used.

Uff that makes me think again whether there should be a free vs non-free toggle for every vendor stack 😄, if someone finds time to test and compare it and if we find a way to implement it without making it too complicated.

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 30, 2023

Thinking about it, should we rename the function dedicatedgpu to gpudriver? As these drivers covers both dedicated GPU's and intergrated APU's.
Minor, but still 😄

EDIT: I'll make the changes now. 🈯
EDIT2 | Prompt user to install driver if none during DietPi-Software Xserver?

			# x86_64 VM
			elif (( $G_HW_ARCH == 10 ))
			then		
				local gpu_current=$(sed -n '/^[[:blank:]]*CONFIG_GPU_DRIVER=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
				#VM
				if (( $G_HW_MODEL == 20 ))
				then
					# If KMS/DRM is supported, add VMware DDX, which offers slightly better performance compared to modesetting. VirtualBox can emulate it as well, which is even the nowadays recommended default.
					# Else (e.g. Hyper-V) add classic framebuffer DDX
					[[ -d '/dev/dri' ]] && aDEPS+=('xserver-xorg-video-vmware') || aDEPS+=('xserver-xorg-video-fbdev')

				#NativePC
				elif (( $G_HW_MODEL == 21 )) && [[ $gpu_current == 'none' ]]

					G_WHIP_YESNO 'No GPU Driver is currently installed.\n\nWould you like to select a GPU driver for installation now?' && /boot/dietpi/dietpi-config 2

				fi

EDIT3: Probably safer to do it after all DietPi-Software installs (https://github.com/Fourdee/DietPi/blob/dev/dietpi/dietpi-software#L13867) Then check for Xserver (or Desktop/Steam)?. Avoid any conflict by ensuring Xserver is installed 1st, before GPU driver?

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 31, 2023

Note to self, idea (got side tracked lol):

Replace gpu_current=$(sed -n '/^[[:blank:]]*CONFIG_GPU_DRIVER=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) (and others), with a Global function?

  • Simplifiy code throughout all DietPi scripts?
  • Parse mode index option for special case return values etc
  • Always return a lower case output? +option
# G_CONFIG_GET
        # - $1 = Item
        # - $2 = File
        # - $3 (optional) = Parse mode # Could be index based system.
        G_CONFIG_GET(){

                [[ $1 && $2 ]] || exit 1
                local return_value=$(sed -n '/^[[:blank:]]*'"$1"'=/{s/^[^=]*=//p;q}' $2)
                [[ $return_value ]] && echo $return_value
        }

Example use

root@DietPi-Zen:/home/dietpi# G_CONFIG_GET CONFIG_GPU_DRIVER /boot/dietpi.txt
none

root@DietPi-Zen:/home/dietpi# [[ $(G_CONFIG_GET CONFIG_GPU_DRIVER /boot/dietpi.txt) == 'none' ]] && echo 0
0

@Fourdee
Copy link
Collaborator Author

Fourdee commented Mar 31, 2023

@MichaIng
All done, ready for review when time permits 👍

MichaIng
MichaIng previously approved these changes Apr 1, 2023
- General | Add missing execute permissions
- DietPi-Patches | Check for i965-va-driver package as Intel driver stack indicator, since we do not install the legacy xserver-xorg-video-intel anymore. Fix and align menu a little, and show it on first package match instead of checking for all of them.
- DietPi-Patches | Offer GPU driver selection as well if Steam is installed
- DietPi-Set_hardware | GPU driver: Mute error messages when marking packages to be uninstalled and only do autoremoval if there are any packages to be uninstalled
@MichaIng
Copy link
Owner

MichaIng commented Apr 1, 2023

Great work, many thanks! I tested it on a Laptop and applied some fine tuning to the menus (see last commits).

@MichaIng MichaIng merged commit cb6bf08 into MichaIng:dev Apr 1, 2023
@Fourdee
Copy link
Collaborator Author

Fourdee commented Apr 2, 2023

@MichaIng

see last commits

Legend 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Steam + Vulkan support (Proton) | Notes
3 participants