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

Is it possible to use GPU for nvenc encoder? #4423

Open
wfcola opened this issue Nov 21, 2024 · 1 comment
Open

Is it possible to use GPU for nvenc encoder? #4423

wfcola opened this issue Nov 21, 2024 · 1 comment
Labels
bug Something isn't working encoding

Comments

@wfcola
Copy link

wfcola commented Nov 21, 2024

I tried to using nvenc for video encoder following the doc below:
https://github.com/Xpra-org/xpra/blob/master/docs/Usage/NVENC.md

I am not sure about wheather it's running properly. client.connection.encoder always using rencodeplus and GPU is not working(GPU can be found using nvidia-smi and xpra nvinfo, and it could work when running simulation program). xpra took about 20% of CPU when send updated desktop image to web client.

After all the running conditions are met, I run xpra. Through the xpra info | grep encoder command, I get the following output:

docker@a3ba56491117:/$ xpra info | grep encoder
Warning: XDG_RUNTIME_DIR is not defined
 and '/run/user/1000' does not exist
 using '/tmp'
client.connection.encoder=rencodeplus
network.encoders=('rencodeplus', 'none')
server.argv=('/usr/bin/xpra', 'start-desktop', '--bind-tcp=0.0.0.0:12301', '--html=on', '--exit-with-children=yes', '--start-child=xfce4-session', '--video-encoders=nvenc', '--encoding=nvenc', '--quality=20', '--speed=20')
video.encoding.video-encoder.gstreamer=disabled
video.encoding.video-encoder.jpeg=disabled
video.encoding.video-encoder.nvenc=active
video.encoding.video-encoder.nvjpeg=not found
video.encoding.video-encoder.openh264=disabled
video.encoding.video-encoder.vpx=disabled
video.encoding.video-encoder.webp=disabled
video.encoding.video-encoder.x264=disabled

As following the steps in debug, the output of xpra video and xpra encode are as follow:

docker@a3ba56491117:/$ xpra video
Warning: XDG_RUNTIME_DIR is not defined
 and '/run/user/1000' does not exist
 using '/tmp'
CUDA initialization (this may take a few seconds)
CUDA 11.5.0 / PyCUDA 2021.1, found 1 devices:
  + NVIDIA GeForce RTX 4060 Ti @ 0000:01:00.0 (memory: 96% free, compute: 8.9)
NVidia driver version 560.35.3
NVENC v11 successfully initialized with codecs: h264, h265
* csc
  - BGRX_to_YUV420P               : cython
  - BGRX_to_YUV444P               : cython
  - BGR_to_YUV420P                : cython
  - BGR_to_YUV444P                : cython
  - GBRP10_to_r210                : cython
  - GBRP_to_BGRX                  : cython
  - GBRP_to_RGBX                  : cython
  - RGBX_to_YUV420P               : cython
  - RGBX_to_YUV444P               : cython
  - RGB_to_YUV420P                : cython
  - RGB_to_YUV444P                : cython
  - YUV420P_to_BGR                : cython
  - YUV420P_to_BGRX               : cython
  - YUV420P_to_RGB                : cython
  - YUV420P_to_RGBX               : cython
  - YUV444P10_to_r210             : cython
  - YUV444P_to_BGRX               : cython
  - YUV444P_to_RGBX               : cython
  - r210_to_BGR48                 : cython
  - r210_to_YUV420P               : cython
  - r210_to_YUV444P10             : cython
* decoding
  - av1_to_YUV420P                : gstreamer
  - h264_to_YUV420P               : openh264, gstreamer
  - vp8_to_YUV420P                : vpx, gstreamer
  - vp9_to_YUV420P                : vpx, gstreamer
  - vp9_to_YUV444P                : vpx
* encoding
  - ARGB_to_h264                  : nvenc
  - ARGB_to_h265                  : nvenc
  - BGR48_to_h264                 : x264
  - BGRA_to_jpega                 : jpeg
  - BGRA_to_webp                  : webp
  - BGRX_to_h264                  : nvenc, x264
  - BGRX_to_h265                  : nvenc
  - BGRX_to_jpeg                  : jpeg
  - BGRX_to_webp                  : webp
  - BGR_to_jpeg                   : jpeg
  - BGR_to_webp                   : webp
  - RGBA_to_jpega                 : jpeg
  - RGBA_to_webp                  : webp
  - RGBX_to_jpeg                  : jpeg
  - RGBX_to_webp                  : webp
  - RGB_to_jpeg                   : jpeg
  - RGB_to_webp                   : webp
  - XBGR_to_jpeg                  : jpeg
  - XRGB_to_h264                  : nvenc
  - XRGB_to_h265                  : nvenc
  - XRGB_to_jpeg                  : jpeg
  - YUV420P_to_av1                : gstreamer-av1enc
  - YUV420P_to_h264               : gstreamer-x264enc, gstreamer-openh264enc, openh264, x264
  - YUV420P_to_jpeg               : jpeg
  - YUV420P_to_vp8                : gstreamer-vp8enc, vpx
  - YUV420P_to_vp9                : vpx
  - YUV422P_to_h264               : x264
  - YUV422P_to_jpeg               : jpeg
  - YUV444P10_to_vp9              : vpx
  - YUV444P_to_av1                : gstreamer-av1enc
  - YUV444P_to_h264               : gstreamer-x264enc, x264
  - YUV444P_to_jpeg               : jpeg
  - YUV444P_to_vp9                : gstreamer-vp9enc, vpx
  - csc-module
    - cython                      : active
    - libyuv                      : active
  - r210_to_h264                  : nvenc
  - r210_to_h265                  : nvenc
  - video-encoder
    - gstreamer                   : active
    - jpeg                        : active
    - nvenc                       : active
    - nvjpeg                      : active
    - openh264                    : active
    - vpx                         : active
    - webp                        : active
    - x264                        : active
* gpu
  - csc                           : ()
  - decodings                     : ()
  - encodings                     : h264, h265

docker@a3ba56491117:/$ xpra encoding
Warning: XDG_RUNTIME_DIR is not defined
 and '/run/user/1000' does not exist
 using '/tmp'
CUDA initialization (this may take a few seconds)
CUDA 11.5.0 / PyCUDA 2021.1, found 1 devices:
  + NVIDIA GeForce RTX 4060 Ti @ 0000:01:00.0 (memory: 96% free, compute: 8.9)
NVidia driver version 560.35.3
NVENC v11 successfully initialized with codecs: h264, h265
modules found:
* csc_cython           : usr/lib/python3/dist-packages/xpra/codecs/csc_cython/converter.cpython-310-x86_64-linux-gnu.so
* csc_libyuv           : No module named 'xpra.codecs.libyuv'
* dec_avif             : usr/lib/python3/dist-packages/xpra/codecs/avif/decoder.cpython-310-x86_64-linux-gnu.so
* dec_gstreamer        : usr/lib/python3/dist-packages/xpra/codecs/gstreamer/decoder.py
* dec_jpeg             : usr/lib/python3/dist-packages/xpra/codecs/jpeg/decoder.cpython-310-x86_64-linux-gnu.so
* dec_nvjpeg           : libnvjpeg.so.12: cannot open shared object file: No such file or directory
* dec_openh264         : usr/lib/python3/dist-packages/xpra/codecs/openh264/decoder.cpython-310-x86_64-linux-gnu.so
* dec_pillow           : usr/lib/python3/dist-packages/xpra/codecs/pillow/decoder.py
* dec_spng             : No module named 'xpra.codecs.spng'
* dec_vpx              : usr/lib/python3/dist-packages/xpra/codecs/vpx/decoder.cpython-310-x86_64-linux-gnu.so
* dec_webp             : usr/lib/python3/dist-packages/xpra/codecs/webp/decoder.cpython-310-x86_64-linux-gnu.so
* drm                  : usr/lib/python3/dist-packages/xpra/codecs/drm/drm.cpython-310-x86_64-linux-gnu.so
* enc_avif             : usr/lib/python3/dist-packages/xpra/codecs/avif/encoder.cpython-310-x86_64-linux-gnu.so
* enc_gstreamer        : usr/lib/python3/dist-packages/xpra/codecs/gstreamer/encoder.py
* enc_jpeg             : usr/lib/python3/dist-packages/xpra/codecs/jpeg/encoder.cpython-310-x86_64-linux-gnu.so
* enc_nvjpeg           : libnvjpeg.so.12: cannot open shared object file: No such file or directory
* enc_openh264         : usr/lib/python3/dist-packages/xpra/codecs/openh264/encoder.cpython-310-x86_64-linux-gnu.so
* enc_pillow           : usr/lib/python3/dist-packages/xpra/codecs/pillow/encoder.py
* enc_rgb              : usr/lib/python3/dist-packages/xpra/codecs/argb/encoder.py
* enc_spng             : No module named 'xpra.codecs.spng'
* enc_vpx              : usr/lib/python3/dist-packages/xpra/codecs/vpx/encoder.cpython-310-x86_64-linux-gnu.so
* enc_webp             : usr/lib/python3/dist-packages/xpra/codecs/webp/encoder.cpython-310-x86_64-linux-gnu.so
* enc_x264             : usr/lib/python3/dist-packages/xpra/codecs/x264/encoder.cpython-310-x86_64-linux-gnu.so
* evdi                 : No module named 'xpra.codecs.evdi'
* nvdec                : No module named 'xpra.codecs.nvidia.nvdec'
* nvenc                : usr/lib/python3/dist-packages/xpra/codecs/nvidia/nvenc/encoder.cpython-310-x86_64-linux-gnu.so
* nvfbc                : usr/lib/python3/dist-packages/xpra/codecs/nvidia/nvfbc/capture_linux.cpython-310-x86_64-linux-gnu.so
* v4l2                 : usr/lib/python3/dist-packages/xpra/codecs/v4l2/virtual.cpython-310-x86_64-linux-gnu.so

codecs versions:
* avif                            : 0.9.3
* cython                          : 4.2
* drm                             : 4.4
* gstreamer                       : 5.0
* jpeg                            : 1.0
* numpy                           : 1.26.4
* nvenc                           : 11.0
* nvfbc                           : 1.7
* openh264                        : 2.2.0
* pillow                          : 11.0.0
* rgb                             : 6.0
* v4l2                            : 1.0
* vpx                             : 1.11.0
* webp                            : 1.2.2
* x264                            : 163

So if is it possible to use GPU to encode? Or what did I miss?

@wfcola wfcola added the bug Something isn't working label Nov 21, 2024
@wfcola wfcola changed the title If is it possible to use GPU for nvenc encoder? Is it possible to use GPU for nvenc encoder? Nov 21, 2024
@totaam
Copy link
Collaborator

totaam commented Nov 21, 2024

Do not disable the other video encoders.
nvenc will be used as needed.

when send updated desktop image to web client.

Try with the python client first.
There is an issue with the html5 client: https://github.com/orgs/Xpra-org/discussions/4422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working encoding
Projects
None yet
Development

No branches or pull requests

2 participants