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

add support for nvenc and accel_assist #3320

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

jsorg71
Copy link
Contributor

@jsorg71 jsorg71 commented Nov 20, 2024

No description provided.

@matt335672
Copy link
Member

Fix some build issues with:-

--- a/scripts/install_xrdp_build_dependencies_with_apt.sh
+++ b/scripts/install_xrdp_build_dependencies_with_apt.sh
@@ -74,6 +74,7 @@ case "$ARCH"
 in
     amd64)
         PACKAGES_AMD64_MIN=" \
+            libepoxy-dev \
             libpam0g-dev \
             libssl-dev \
             libx11-dev \
@@ -118,6 +119,7 @@ in
         PACKAGES="$PACKAGES \
             g++-multilib \
             gcc-multilib \
+            libepoxy-dev:i386 \
             $LIBFREETYPE_DEV:i386 \
             libgl1-mesa-dev:i386 \
             libglu1-mesa-dev:i386 \

Also:-

  1. some files are missing from the xrdp_accel_assist directory; xrdp_accel_assist_yami.c xrdp_accel_assist_yami.h encoder_headers/yami_inf.h
  2. need to run astyle

Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

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

Happy to merge this as-is, when CI is fixed.

g_deinit();
g_exit(0);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggest adding error logging if this doesn't work, for triaging user issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't t think the log ing system is initialized at this point. Can we still log?

Copy link
Member

Choose a reason for hiding this comment

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

You're quite right. Calling LOG() won't work.

Two possible solutions:-

  1. Log errors to stderr in this function. This isn't ideal, but it will at least get picked up by the journal on systemd-based systems.
  2. Use a separate function for this purpose (g_cu_init()?) called explicitly from sesman after logging has started. We can remove it if you ever get a better answer as to why this function is required.

@matt335672
Copy link
Member

I don't want to hold up merging this, but I'd like to ask if we think the hack to call cuInit() is in the right place. Wouldn't it be better done as part of the session if NVidia is being used?

@jsorg71
Copy link
Contributor Author

jsorg71 commented Dec 4, 2024

I don't want to hold up merging this, but I'd like to ask if we think the hack to call cuInit() is in the right place. Wouldn't it be better done as part of the session if NVidia is being used?

I tried to just call cuInit() in the session but as the user it fails. Once the call is made as root, something gets 'driver init' and then it will work as the user. I guess xrdp might not be running as root, is that right? Also, is this a security risk?
In order to reproduce this problem, you have to boot a server up without X GUI running as Xorg on console also does the 'driver init'.
I tried to use nvida_persistence or something like that as it claimed to fix this but it didn't work.
I've been meaning to ask NVidia about this but the problem is hard to describe.

@jsorg71
Copy link
Contributor Author

jsorg71 commented Dec 4, 2024

I rebased this branch on current devel

@jsorg71
Copy link
Contributor Author

jsorg71 commented Dec 4, 2024

Should we make xrdp_accel_assit a compile time flag because with it, epoxy and gbm are required to build xrdp. We didn't need that before? Xorg, or at least the modesetting driver requires the run time libraries but now we require the development packages and the user may never plan to use xrdp_accel_assist.

@matt335672
Copy link
Member

As far as the cuInit() goes, either sesman or sesexec runs as root. Since #2974, xrdp may not be running as root, and in fact it won't be on Debian/Ubuntu anyway - they patched it to run as non-root a long time ago.

I think a compile-time option is the best way to go, for platforms that may not support NVidia acceleration (are there any?).

@jsorg71
Copy link
Contributor Author

jsorg71 commented Dec 24, 2024

As far as the cuInit() goes, either sesman or sesexec runs as root. Since #2974, xrdp may not be running as root, and in fact it won't be on Debian/Ubuntu anyway - they patched it to run as non-root a long time ago.

I think a compile-time option is the best way to go, for platforms that may not support NVidia acceleration (are there any?).

done and done

@jsorg71
Copy link
Contributor Author

jsorg71 commented Dec 24, 2024

accel_assist is using environment variables set int sesman.ini, but I think it might be better to use gfx.toml.

these are the current env vars. @metalefty can accell_assist use gfx.toml, does that make sense to use?

XRDP_NVENC_RATE_CONTROL_MODE
XRDP_NVENC_AVERAGE_BITRATE
XRDP_NVENC_QP

@metalefty
Copy link
Member

Yes, it looks good to me.

Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

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

One comment on recent changes. I'm still happy to merge this sooner rather than later and work in devel if that suits.

g_deinit();
g_exit(0);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

You're quite right. Calling LOG() won't work.

Two possible solutions:-

  1. Log errors to stderr in this function. This isn't ideal, but it will at least get picked up by the journal on systemd-based systems.
  2. Use a separate function for this purpose (g_cu_init()?) called explicitly from sesman after logging has started. We can remove it if you ever get a better answer as to why this function is required.

@jsorg71
Copy link
Contributor Author

jsorg71 commented Jan 7, 2025

I'm good to merge this now and then continue work in devel.

@matt335672
Copy link
Member

Fine by me - it will get more exposure that way.

I've got #3346 to merge once @metalefty has looked at it, but it won't affect this at all.

@Nexarian
Copy link
Contributor

Nexarian commented Jan 7, 2025

Agreed.

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