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

flatpak launcher #2207

Merged
merged 13 commits into from
Aug 16, 2024
Merged

flatpak launcher #2207

merged 13 commits into from
Aug 16, 2024

Conversation

failboat78
Copy link
Collaborator

To enable nvidia encoding inside flatpak we need to build ffmpeg with cuda support. This needs the nvcc compiler - which is not easily obtainable via flatpak. The current freedesktop nvidia driver packages have the driver but are missing nvcc. In the future maybe there will be some sdk extension package that can be added to enable this.

But for now, we can add the hosts cuda folder to the flatpak build env and get it to work. I'm using arch which has a non-standard install location for cuda (/opt/cuda) - other distros might use different. NVCC is also fussy about it's gcc version - 13.2 is the max supported right now. But arch comes with gcc-14 so even without flatpak this requires extra settings. Flatpak actually makes this easier because the runtime used has 13.2 right now.

So the changes needed are quite small, we just copy cuda into the build folder, and update the pkgconfig to point to it. Then just set some env variables and the build works. Note that NVCC is only needed for the build, not at runtime.

Improvements that can be made:
Print error if cuda not installed - or continue without nvidia support
Detect where host has cuda installed, update paths to reflect

Testing:
Works well for me with arch+flatpak steam+4090 555+kde plasma 6.1.
Does this also work for amd users? Would there be an nvidia vs non-nvidia version needed?

@failboat78
Copy link
Collaborator Author

Oh yeah I could not get the desktop shortcut part to work. The copy command just says folder does not exist - not sure how to do this properly so I just commented it out.

@Meister1593
Copy link
Collaborator

Honestly i thought about changing flatpak to just instructions on how to run portable under flatpak container, since it seemed to work for nvidia users

@Meister1593
Copy link
Collaborator

Meister1593 commented Jun 24, 2024

What formatter was used for json? It looks a bit odd...

@failboat78
Copy link
Collaborator Author

Just vscode defaults, sorry for mangling it!

And yes - this flatpak should work for all users - but I have no AMD to test on. This is same method blender and other programs support nvidia via flatpak.

@failboat78
Copy link
Collaborator Author

Another improvement is to download cuda rather than copy from host: https://developer.nvidia.com/cuda-toolkit-archive

This would be quite elegant then, and provide a completely portable build environment?

@zmerp
Copy link
Member

zmerp commented Jun 25, 2024

@failboat78 Unfortunately nvidia requires you to give personal details before download. So we cannot automate it. From experience, installing cuda packages may break the system, when not provided by the distro package manager. So maybe we should add the option to link from a user provide directory?

@failboat78
Copy link
Collaborator Author

@failboat78 Unfortunately nvidia requires you to give personal details before download. So we cannot automate it. From experience, installing cuda packages may break the system, when not provided by the distro package manager. So maybe we should add the option to link from a user provide directory?

They must have changed their website, it's possible to download those cuda archives without a login. It does want you to accept license when you install tho, but this can be automated.

Test: wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run

Using flatpak we avoid the usual "breaking the system" problems. We are just using this cuda to do our build, then discarding it. There should be no system to break.

I'll commit improvements in near future.

@failboat78
Copy link
Collaborator Author

@zarik5 @Meister1593 now it should be fully automated portable build.

But cuda download is 4.1GB so can cause large delay dependent on internet speed.

I was not able to run the cuda installer in the normal fashion - it would segfault. As a workaround I had to use the raw extract option which is provided for weird cases like this. The nvidia software is split between several folders internally - so I had to update pkgconfig to use multiple folders.

Pretty tedious stuff!

@Meister1593
Copy link
Collaborator

Same flatpak file is also used for pipelines, i have a feeling this needs to be set up with caching for sure, and maybe even separated?...

@failboat78
Copy link
Collaborator Author

Yes we need to cache this cuda stuff. I am trying to figure out how best to do that with flatpak - maybe moving cuda to it's own extension, or another module.

Copy link
Collaborator

@Meister1593 Meister1593 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm overall fine with this, but i still wonder if you can just run launcher + alvr under flatpak without any of this
Could you try to:

  1. Downloading launcher https://github.com/alvr-org/ALVR/releases/download/v20.9.1/alvr_launcher_linux.tar.gz
  2. Putting it into ~/.var/app/com.valvesoftware.Steam
  3. Launching it with flatpak run --command='~/.var/app/com.valvesoftware.Steam/ALVR Launcher' com.valvesoftware.Steam (or similar to just be able to run it under runtime)
  4. Installing alvr stable version, trying to run it under flatpak steam all as usual with all fixes from troubleshooting

@failboat78
Copy link
Collaborator Author

failboat78 commented Jul 15, 2024

@Meister1593

Sure - I will start looking at how to include the launcher with flatpak.

But that seems like a seperate task - not related to all the nvidia nonsense here. Can we please merge this one and I will open a new PR for launcher flatpak stuff?

If we don't use the stuff here (which is purely build related) then that is fine - I just wanted to learn more about the build process. And the same stuff can be used to package the launcher too hopefully. What I am clueless about is the interaction between steam vs steamvr vs alvr vs launcher - this requires some study.

@Meister1593
Copy link
Collaborator

Meister1593 commented Jul 15, 2024

@Meister1593

Sure - I will start looking at how to include the launcher with flatpak.

But that seems like a seperate task - not related to all the nvidia nonsense here. Can we please merge this one and I will open a new PR for launcher flatpak stuff?

If we don't use the stuff here (which is purely build related) then that is fine - I just wanted to learn more about the build process. And the same stuff can be used to package the launcher too hopefully. What I am clueless about is the interaction between steam vs steamvr vs alvr vs launcher - this requires some study.

Then only one question, related to cache, on @zarik5 - is it fine? It has big size (more than gb) a bit as far as i can tell and there was an issue with space we had available.

If it's impossible, then launcher could be the only option

@zmerp
Copy link
Member

zmerp commented Jul 15, 2024

If cache is a problem we can remove the MSRV jobs

@Meister1593
Copy link
Collaborator

I'm overall fine with this, but i still wonder if you can just run launcher + alvr under flatpak without any of this Could you try to:

1. Downloading launcher https://github.com/alvr-org/ALVR/releases/download/v20.9.1/alvr_launcher_linux.tar.gz

2. Putting it into `~/.var/app/com.valvesoftware.Steam`

3. Launching it with `flatpak run --command='~/.var/app/com.valvesoftware.Steam/ALVR Launcher' com.valvesoftware.Steam` (or similar to just be able to run it under runtime)

4. Installing alvr stable version, trying to run it under flatpak steam all as usual with all fixes from troubleshooting

Just double checked that case on amd - it works completely fine

@Meister1593
Copy link
Collaborator

If cache is a problem we can remove the MSRV jobs

don't think removing them is a good idea?... they are pretty useful

@zmerp
Copy link
Member

zmerp commented Jul 15, 2024

don't think removing them is a good idea?... they are pretty useful

We can make so it runs only for release branches or remove its (rust) cache. But we did not hit the limit yet.

@Meister1593
Copy link
Collaborator

I think we can push it as is without auto-installing desktop file
This is anyway better than before, with nvidia working

Just update flatpak wiki page and we can merge it

Copy link
Collaborator

@Meister1593 Meister1593 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert removal of flatpak page (it's useful), make it just specific for launcher and note how you can install desktop file

@zmerp
Copy link
Member

zmerp commented Jul 30, 2024

@failboat78 ping?

@failboat78
Copy link
Collaborator Author

I'm confused - what changes are we doing? Do we want a completely seperate PR for the launcher stuff? This original PR was mostly concerned with using flatpak as a build environment - which is very different.

If that's what we want I will revert and make a new PR for the launcher.

…esktop shortcut (does not work but at least its in there)
Copy link
Collaborator

@Meister1593 Meister1593 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only thing left is to update the wiki and that's it

@The-personified-devil should it be in the same pr or could be done separately? (just to not stall pr), what do you think?

@The-personified-devil
Copy link
Collaborator

@The-personified-devil should it be in the same pr or could be done separately? (just to not stall pr), what do you think?

merge this first, wiki prs are really quick to merge

add some convenience scripts for build/install/setup shortcut and icon
converted windows ico file to png for use on linux

known issues: file browser and apk buttons do not work in launcher

still testing
@Meister1593
Copy link
Collaborator

Meister1593 commented Aug 11, 2024

Adb working under flatpak probably requires dashboard-side changes (to run different command), for now i think it can be skipped, just note that in wiki page later
skylot/jadx#2214 flatpak-spawn might be useful there

@Meister1593 Meister1593 self-requested a review August 11, 2024 11:54
Meister1593
Meister1593 previously approved these changes Aug 11, 2024
@failboat78
Copy link
Collaborator Author

I got adb working under flatpak and updated readme.

However I am still not able to run a complete VR test because it seems a lot of stuff graphics and steamvr got updated in last few weeks.


```
flatpak run org.flatpak.Builder --user --install --force-clean .flatpak-build-dir alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json
cd alvr/xtask/flatpak
./build_and_install.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script requires host flatpak builder, but before it was from flatpak itself

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flatpak-builder vs flatpak run org.flatpak.Builder

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides this, everything else works fine on amdgpu
If this changed it can be merged just fine

small edits to readme for clarity
@Meister1593 Meister1593 self-requested a review August 15, 2024 18:16
Meister1593
Meister1593 previously approved these changes Aug 15, 2024
@Meister1593 Meister1593 self-requested a review August 16, 2024 16:16
Copy link
Collaborator

@Meister1593 Meister1593 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge for now, update nightly and check if it builds correctly there as well (you can try building it on your repo (ignoring android build) and see if flatpak is correct)
If it works, then most likely release build should work fine as well.

And of course, update wiki too.

@Meister1593 Meister1593 merged commit cc89dea into alvr-org:master Aug 16, 2024
8 checks passed
szneqz pushed a commit to szneqz/ALVR that referenced this pull request Aug 21, 2024
* flatpak nvidia

* wip

* now downloads cuda rather than copying from host

* move cuda to own module so it can be cached

* fix cuda build - but also make cuda build redundant via launcher

* remove all unnecessary stuff, only launcher left

* remove spurious module, add simple build script, attempt copying of desktop shortcut (does not work but at least its in there)

* put readme back - and update it with new info
add some convenience scripts for build/install/setup shortcut and icon
converted windows ico file to png for use on linux

known issues: file browser and apk buttons do not work in launcher

still testing

* update readme, add notes and convenience scripts for adb install in flatpak

* change build back to org.flatpak.Builder
small edits to readme for clarity

* add note warning about nvidia and hdr

* note about pipewire

---------

Co-authored-by: failboat <[email protected]>
zmerp pushed a commit that referenced this pull request Sep 10, 2024
* flatpak nvidia

* wip

* now downloads cuda rather than copying from host

* move cuda to own module so it can be cached

* fix cuda build - but also make cuda build redundant via launcher

* remove all unnecessary stuff, only launcher left

* remove spurious module, add simple build script, attempt copying of desktop shortcut (does not work but at least its in there)

* put readme back - and update it with new info
add some convenience scripts for build/install/setup shortcut and icon
converted windows ico file to png for use on linux

known issues: file browser and apk buttons do not work in launcher

still testing

* update readme, add notes and convenience scripts for adb install in flatpak

* change build back to org.flatpak.Builder
small edits to readme for clarity

* add note warning about nvidia and hdr

* note about pipewire

---------

Co-authored-by: failboat <[email protected]>
@zmerp zmerp mentioned this pull request Sep 10, 2024
zmerp pushed a commit that referenced this pull request Sep 10, 2024
* flatpak nvidia

* wip

* now downloads cuda rather than copying from host

* move cuda to own module so it can be cached

* fix cuda build - but also make cuda build redundant via launcher

* remove all unnecessary stuff, only launcher left

* remove spurious module, add simple build script, attempt copying of desktop shortcut (does not work but at least its in there)

* put readme back - and update it with new info
add some convenience scripts for build/install/setup shortcut and icon
converted windows ico file to png for use on linux

known issues: file browser and apk buttons do not work in launcher

still testing

* update readme, add notes and convenience scripts for adb install in flatpak

* change build back to org.flatpak.Builder
small edits to readme for clarity

* add note warning about nvidia and hdr

* note about pipewire

---------

Co-authored-by: failboat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants