-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Related: #688
Hi Almar! It was nice to quasi-meet you today! I'd love to sit down for a chat about WGPU/Pygfx soon as I'm starting to use and learn more about it, I think it's incredibly impressive work!
I'm trying to roll a fastplotlib widget out to users on older Ubuntu systems. For some this is the only machine they have access to and it's heavily used, so before I ask the admin to install or update drivers, I really want to make sure I know exactly what the problem is and what needs to be done.
This widget is working on jupyter, and offscreen tests with Vulkan are working, so it seems to me specifically a problem with configuring the canvas during window creation.
Reproducible example
I am testing with two scripts, one to enumerate devices and make an image widget, another to attempt creating a Qt canvas because I have other Qt applications that open on the sever (e.g. the suite2p gui and napari).
1. Test surface creation
import os
# The result is the same no matter what values are entered here. Vulkan worked offscreen
#os.environ['WGPU_BACKEND_TYPE'] = 'Vulkan'
#os.environ['RENDERCANVAS_BACKEND'] = 'qt'
import numpy as np
import wgpu
import fastplotlib as fpl
adapters = wgpu.gpu.enumerate_adapters_sync()
print(f"Found {len(adapters)} adapters\n")
for idx, adapter in enumerate(adapters):
info = adapter.info
print(f"[{idx}] {info.get('device')} ({info.get('backend_type')})")
try:
device = adapter.request_device_sync()
limits = device.limits
print(f" max-texture-2d: {limits.get('max-texture-dimension-2d')}")
except Exception as e:
print(f" ERROR: {e}")
data = np.random.rand(10, 512, 512).astype(np.float32)
iw = fpl.ImageWidget(data=data, histogram_widget=True)
iw.show()
fpl.loop.run()Result:
foconnell@v-gpu2:~/repos/mbo_utilities$ RUST_BACKTRACE=full uv run tests/test_surface_creation.py
Unable to find extension: VK_EXT_physical_device_drm
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to get drm magic
Found 6 adapters
[0] NVIDIA TITAN V (Vulkan)
max-texture-2d: 32768
[1] llvmpipe (LLVM 15.0.7, 256 bits) (Vulkan)
max-texture-2d: 16384
[2] NVIDIA GeForce RTX 3090 Ti (Vulkan)
max-texture-2d: 32768
[3] NVIDIA TITAN V (Vulkan)
max-texture-2d: 32768
[4] NVIDIA TITAN V (Vulkan)
max-texture-2d: 32768
[5] llvmpipe (LLVM 15.0.7, 256 bits) (OpenGL)
max-texture-2d: 16384
Testing ImageWidget...
thread '<unnamed>' panicked at src/lib.rs:606:5:
Error in wgpuSurfaceConfigure: Validation Error
Caused by:
Not enough memory left.
stack backtrace:
0: 0x7f172ad28ba2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdcfcb6d4c8489523
1: 0x7f172ad4a293 - core::fmt::write::h8a494366950f23bb
2: 0x7f172ad26953 - std::io::Write::write_fmt::h6556609fca33d0b1
3: 0x7f172ad289f2 - std::sys::backtrace::BacktraceLock::print::hb2a626a81e06b2dc
4: 0x7f172ad29a93 - std::panicking::default_hook::{{closure}}::h4f78485264f12d10
5: 0x7f172ad29875 - std::panicking::default_hook::h2c66fc99e962531d
6: 0x7f172ad2a4a5 - std::panicking::rust_panic_with_hook::h33ac55f64bbd807d
7: 0x7f172ad2a23a - std::panicking::begin_panic_handler::{{closure}}::h30e7cb89678a57fe
8: 0x7f172ad290a9 - std::sys::backtrace::__rust_end_short_backtrace::hed60f27456c16ced
9: 0x7f172ad29ecd - __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
10: 0x7f172ad47c50 - core::panicking::panic_fmt::h62f63d096dd276af
11: 0x7f172a8539b6 - wgpu_native::handle_error_fatal::h25a3665c7d3e2579
12: 0x7f172a869679 - wgpuSurfaceConfigure
13: 0x7f17321dc052 - ffi_call_unix64
14: 0x7f17321da9bd - ffi_call_int
15: 0x7f17321dab38 - cffistatic_ffi_call
16: 0x7f17321c262c - cdata_call
17: 0x1620bd8 - _PyEval_EvalFrameDefault
18: 0x1611cd0 - method_vectorcall.llvm.2544469730125712706
19: 0x162437e - _PyEval_EvalFrameDefault
20: 0x1611cd0 - method_vectorcall.llvm.2544469730125712706
21: 0x162437e - _PyEval_EvalFrameDefault
22: 0x164bb5c - slot_tp_init
23: 0x16027a3 - type_call
24: 0x161497a - _PyEval_EvalFrameDefault
25: 0x164bc6f - slot_tp_init
26: 0x16027a3 - type_call
27: 0x1620bd8 - _PyEval_EvalFrameDefault
28: 0x164bc6f - slot_tp_init
29: 0x16027a3 - type_call
30: 0x161497a - _PyEval_EvalFrameDefault
31: 0x16996e2 - PyEval_EvalCode
32: 0x16b3e82 - run_mod.llvm.11839558314017990275
33: 0x17c005d - pyrun_file
34: 0x17bfdec - _PyRun_SimpleFileObject
35: 0x17bfcc2 - _PyRun_AnyFileObject
36: 0x17bfc04 - pymain_run_file_obj
37: 0x17bfb18 - pymain_run_file
38: 0x17558fb - Py_RunMain
39: 0x17dcd3a - pymain_main.llvm.11357162329980987376
40: 0x17dcb2d - main
41: 0x7f17b1c29d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
42: 0x7f17b1c29e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
43: 0x17bb1ad - _start
44: 0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5, aborting2. Create Qt surface
import os
import wgpu
adapter = wgpu.gpu.request_adapter_sync(power_preference="high-performance")
print(f" Request adapter sync: {adapter.info.get('device')}")
device = adapter.request_device_sync()
print(" Device created successfully: \n {device}")
print("\nCreate Qt canvas")
try:
from qtpy import QtWidgets
import sys
from rendercanvas.qt import QRenderCanvas
print("Creating app")
app = QtWidgets.QApplication(sys.argv)
print(" Qt app created")
print("Creating canvas")
canvas = QRenderCanvas(size=(800, 600), title="Test")
print(" Qt canvas created")
print("Retrieve wgpu context")
present_context = canvas.get_wgpu_context()
print(f" Context: {present_context}")
print("\nConfigure context")
render_texture_format = present_context.get_preferred_format(adapter)
present_context.configure(device=device, format=render_texture_format)
print(" Context configured")
except Exception as e:
print(f"\nFailed with error: {e}")
import traceback
traceback.print_exc()
foconnell@v-gpu2:~/repos/mbo_utilities$ RUST_BACKTRACE=full uv run tests/test_minimal_surface.py
Unable to find extension: VK_EXT_physical_device_drm
libEGL warning: egl: failed to create dri2 screen
libEGL warning: DRI2: failed to get drm magic
Request adapter sync: NVIDIA TITAN V
Device created successfully:
{device}
Create Qt canvas
Creating app
Qt app created
Creating canvas
libGL error: glx: failed to create dri3 screen
libGL error: failed to load driver: nouveau
libGL error: failed to get magic
libGL error: failed to load driver: nouveau
Qt canvas created
Retrieve wgpu context
Context: <rendercanvas.contexts.WgpuContextToScreen object at 0x7f4674a90fe0>
Configure context
thread '<unnamed>' panicked at src/lib.rs:606:5:
Error in wgpuSurfaceConfigure: Validation Error
Caused by:
Not enough memory left.
stack backtrace:
0: 0x7f4674728ba2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdcfcb6d4c8489523
1: 0x7f467474a293 - core::fmt::write::h8a494366950f23bb
2: 0x7f4674726953 - std::io::Write::write_fmt::h6556609fca33d0b1
3: 0x7f46747289f2 - std::sys::backtrace::BacktraceLock::print::hb2a626a81e06b2dc
4: 0x7f4674729a93 - std::panicking::default_hook::{{closure}}::h4f78485264f12d10
5: 0x7f4674729875 - std::panicking::default_hook::h2c66fc99e962531d
6: 0x7f467472a4a5 - std::panicking::rust_panic_with_hook::h33ac55f64bbd807d
7: 0x7f467472a23a - std::panicking::begin_panic_handler::{{closure}}::h30e7cb89678a57fe
8: 0x7f46747290a9 - std::sys::backtrace::__rust_end_short_backtrace::hed60f27456c16ced
9: 0x7f4674729ecd - __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
10: 0x7f4674747c50 - core::panicking::panic_fmt::h62f63d096dd276af
11: 0x7f46742539b6 - wgpu_native::handle_error_fatal::h25a3665c7d3e2579
12: 0x7f4674269679 - wgpuSurfaceConfigure
13: 0x7f46759ae052 - ffi_call_unix64
14: 0x7f46759ac9bd - ffi_call_int
15: 0x7f46759acb38 - cffistatic_ffi_call
16: 0x7f467599462c - cdata_call
17: 0x1620bd8 - _PyEval_EvalFrameDefault
18: 0x1611cd0 - method_vectorcall.llvm.2544469730125712706
19: 0x162437e - _PyEval_EvalFrameDefault
20: 0x1611cd0 - method_vectorcall.llvm.2544469730125712706
21: 0x162437e - _PyEval_EvalFrameDefault
22: 0x16996e2 - PyEval_EvalCode
23: 0x16b3e82 - run_mod.llvm.11839558314017990275
24: 0x17c005d - pyrun_file
25: 0x17bfdec - _PyRun_SimpleFileObject
26: 0x17bfcc2 - _PyRun_AnyFileObject
27: 0x17bfc04 - pymain_run_file_obj
28: 0x17bfb18 - pymain_run_file
29: 0x17558fb - Py_RunMain
30: 0x17dcd3a - pymain_main.llvm.11357162329980987376
31: 0x17dcb2d - main
32: 0x7f4675a29d90 - __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
33: 0x7f4675a29e40 - __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
34: 0x17bb1ad - _start
35: 0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5, abortingI was first getting a generic surface creation threads panic error alone, I then asked the admin of this system to add me to the render and video user groups. Only then I received the memory error above.
Also note: I get the VK_EXT errors, and libEGL errors even when successfully opening napari.
Environment
GPU
foconnell@v-gpu2:~/repos/mbo_utilities$ nvidia-smi
Thu Nov 20 11:29:12 2025
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.23.06 Driver Version: 545.23.06 CUDA Version: 12.3 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA TITAN V On | 00000000:18:00.0 Off | N/A |
| 28% 41C P2 29W / 250W | 90MiB / 12288MiB | 17% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
| 1 NVIDIA TITAN V On | 00000000:3B:00.0 Off | N/A |
| 28% 39C P8 25W / 250W | 5MiB / 12288MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
| 2 NVIDIA GeForce RTX 3090 Ti On | 00000000:5E:00.0 Off | Off |
| 0% 29C P8 19W / 450W | 127MiB / 24564MiB | 12% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
| 3 NVIDIA TITAN V On | 00000000:86:00.0 Off | N/A |
| 28% 37C P8 25W / 250W | 5MiB / 12288MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 4096913 G /usr/lib/xorg/Xorg 85MiB |
| 2 N/A N/A 42373 C+G ...epos/beast_imaging/.venv/bin/python 114MiB |
+---------------------------------------------------------------------------------------+(Relavant sectons of) WGPU Report:
██ system:
platform: Linux-6.2.0-36-generic-x86_64-with-glibc2.35
python_implementation: CPython
python: 3.12.12
██ versions:
wgpu: 0.28.1
cffi: 2.0.0
rendercanvas: 2.4.1
glfw: 2.10.0
numpy: 2.3.5
pygfx: 0.15.3
pylinalg: 0.6.8
fastplotlib: 0.5.2
██ wgpu_native_info:
expected_version: 27.0.2.0
lib_version: 27.0.2.0
lib_path: ./resources/libwgpu_native-release.so
Environment Variables
foconnell@v-gpu2:~/repos/mbo_utilities$ env
SHELL=/bin/bash
SESSION_MANAGER=local/v-gpu2:@/tmp/.ICE-unix/4097139,unix/v-gpu2:/tmp/.ICE-unix/4097139
WINDOWID=6291463
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/home/foconnell/.config/kdedefaults:/etc/xdg
LANGUAGE=
SHELL_SESSION_ID=f87a6aa5a9564b70b9fa9e26ebaa9462
GTK_RC_FILES=/etc/gtk/gtkrc:/home/foconnell/.gtkrc:/home/foconnell/.config/gtkrc
XCURSOR_SIZE=24
GTK_MODULES=gail:atk-bridge
PWD=/home/foconnell/repos/mbo_utilities
KRB5CCNAME=FILE:/tmp/krb5cc_343984073_ybsQCD
LOGNAME=foconnell
XDG_SESSION_TYPE=x11
SYSTEMD_EXEC_PID=598673
PULSE_SCRIPT=/etc/xrdp/pulse/default.pa
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/foconnell/.gtkrc-2.0:/home/foconnell/.config/gtkrc-2.0
HOME=/home/foconnell
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=KDE
KONSOLE_DBUS_SERVICE=:1.4365
XRDP_SOCKET_PATH=/run/xrdp/sockdir
KONSOLE_DBUS_SESSION=/Sessions/2
PROFILEHOME=
XRDP_PULSE_SOURCE_SOCKET=xrdp_chansrv_audio_in_socket_17
KONSOLE_VERSION=211203
KDE_SESSION_UID=343984073
XDG_SESSION_CLASS=user
TERM=xterm-256color
USER=foconnell
COLORFGBG=15;0
XRDP_SESSION=1
KDE_SESSION_VERSION=5
DISPLAY=:17.0
XRDP_PULSE_SINK_SOCKET=xrdp_chansrv_audio_out_socket_17
SHLVL=1
XDG_SESSION_ID=c124
LD_LIBRARY_PATH=/usr/lib64:/usr/lib
XDG_RUNTIME_DIR=/run/user/343984073
QT_AUTO_SCREEN_SCALE_FACTOR=0
XCURSOR_THEME=breeze_cursors
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
KDE_FULL_SESSION=true
PATH=/home/foconnell/anaconda3/bin:/home/foconnell/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda/bin:/usr/local/cuda/bin:/usr/local/cuda/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/343984073/bus
KDE_APPLICATIONS_AS_SCOPE=1
UID=343984073
KONSOLE_DBUS_WINDOW=/Windows/1
_=/usr/bin/envThanks 😃