pygfx: Validation Error on large mesh
Pre version 1.16 I could load a large mesh file, but now I have the following Validation Error, and I am wondering why?
EGL surface: -srgb
No config found!
EGL says it can present to the window but not natively
Draw error
Traceback (most recent call last):
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\wgpu\gui\base.py", line 24, in log_exception
yield
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\wgpu\gui\base.py", line 180, in _draw_frame_and_present
self.draw_frame()
File "c:\users\s.shaji\onedrive - bkw\entwicklung\sms-tools\sms-tools_v3.0.0\src\dialogs\meshviewer.py", line 446, in animate
self._renderer.render(self._scene, self._camera)
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_renderer.py", line 481, in render
container_group = get_pipeline_container_group(wobject, environment)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 166, in get_pipeline_container_group
pipeline_container_group.update(wobject, environment, changed_labels)
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 410, in update
container.update(wobject, environment, changed)
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 476, in update
raise err
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 473, in update
self.update_shader_data(wobject, changed)
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 506, in update_shader_data
self.update_bind_groups()
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 574, in update_bind_groups
binding_des, binding_layout_des = binding.get_bind_group_descriptors(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_pipeline.py", line 240, in get_bind_group_descriptors
"buffer": ensure_wgpu_object(resource),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\pygfx\renderers\wgpu\_update.py", line 155, in ensure_wgpu_object
resource._wgpu_object = device.create_buffer(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\wgpu\backends\wgpu_native\_api.py", line 730, in create_buffer
return self._create_buffer(label, int(size), usage, bool(mapped_at_creation))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\wgpu\backends\wgpu_native\_api.py", line 751, in _create_buffer
id = libf.wgpuDeviceCreateBuffer(self._internal, struct)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Entwicklung\SMS-Tools\env312\Lib\site-packages\wgpu\backends\wgpu_native\_helpers.py", line 314, in proxy_func
raise wgpu_error # the frame above is more interesting ↑↑
^^^^^^^^^^^^^^^^
wgpu.base.GPUValidationError: Validation Error
Caused by:
In wgpuDeviceCreateBuffer
Buffer size 416246112 is greater than the maximum buffer size (268435456)
Draw error: Validation Error (2)
Some stats:
Number of Nodes (geometry.positions) = 17_397_542 = 200 MB (float32)
Number of Mesh triangles (geometry.indices) = 34_687_176 = 396 MB (uint32)
GPU Info:
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 532.03 Driver Version: 532.03 CUDA Version: 12.1 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce GT 1030 WDDM | 00000000:01:00.0 On | N/A |
| 40% 46C P0 N/A / 30W| 492MiB / 2048MiB | 1% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
Python 3.12.0 pip environment:
Package Version
------------------------- ------------
affine 2.4.0
altgraph 0.17.4
asttokens 2.4.1
attrs 23.1.0
certifi 2023.7.22
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
click-plugins 1.1.1
cligj 0.7.2
cloudpickle 3.0.0
colorama 0.4.6
comm 0.2.0
debugpy 1.8.0
decorator 5.1.1
executing 2.0.1
fiona 1.9.5
freetype-py 2.4.0
GDAL 3.7.3
geopandas 0.14.1
h5py 3.10.0
idna 3.4
ipykernel 6.26.0
ipython 8.17.2
jedi 0.19.1
Jinja2 3.1.2
jupyter_client 8.6.0
jupyter_core 5.5.0
MarkupSafe 2.1.3
matplotlib-inline 0.1.6
MeshParser 0.7.0
nest-asyncio 1.5.8
numpy 1.26.2
opencv-python 4.8.1.78
packaging 23.2
pandas 2.1.3
parso 0.8.3
pefile 2023.2.7
Pillow 10.1.0
pip 23.3.1
platformdirs 4.0.0
prompt-toolkit 3.0.41
psutil 5.9.6
pure-eval 0.2.2
pyarrow 14.0.1
pycparser 2.21
pygfx 0.1.16
Pygments 2.16.1
pyinstaller 6.2.0
pyinstaller-hooks-contrib 2023.10
pylinalg 0.4.1
pyogrio 0.7.2
pyparsing 3.1.1
pyproj 3.6.1
PyQt6 6.6.0
PyQt6-Qt6 6.6.0
PyQt6-sip 13.6.0
pyqtgraph 0.13.3
pyshp 2.3.1
python-dateutil 2.8.2
pytz 2023.3.post1
pywin32 306
pywin32-ctypes 0.2.2
pyzmq 25.1.1
QtPy 2.4.1
rasterio 1.3.9
requests 2.31.0
scipy 1.11.3
setuptools 68.2.2
shapely 2.0.2
six 1.16.0
snuggs 1.4.7
spyder-kernels 2.5.0
stack-data 0.6.3
superqt 0.6.1
tornado 6.3.3
tqdm 4.66.1
traitlets 5.13.0
typing_extensions 4.8.0
tzdata 2023.3
uharfbuzz 0.37.3
urllib3 2.1.0
wcwidth 0.2.10
wgpu 0.12.0
Previous Working Environment: Python 3.11.5
Package Version
------------------------- -----------
affine 2.4.0
altgraph 0.17.3
astroid 2.15.5
asttokens 2.2.1
attrs 22.2.0
backcall 0.2.0
black 23.3.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.1.0
click 8.1.3
click-plugins 1.1.1
cligj 0.7.2
cloudpickle 2.2.1
colorama 0.4.6
comm 0.1.2
contourpy 1.1.0
cycler 0.11.0
debugpy 1.6.6
decorator 5.1.1
dill 0.3.6
docstring-to-markdown 0.12
entrypoints 0.4
et-xmlfile 1.1.0
executing 1.2.0
Fiona 1.9.4.post1
fonttools 4.41.1
freetype-py 2.4.0
future 0.18.3
GDAL 3.7.1
geopandas 0.14.0
h5py 3.9.0
idna 3.4
imageio 2.31.0
ipykernel 6.26.0
ipython 8.17.2
isort 5.12.0
jedi 0.18.2
Jinja2 3.1.2
jupyter_client 7.4.9
jupyter_core 5.2.0
kiwisolver 1.4.4
lazy-object-proxy 1.9.0
MarkupSafe 2.1.2
matplotlib-inline 0.1.6
mccabe 0.7.0
MeshParser 0.7.0
mf-visuals 0.0.7
munch 2.5.0
mypy 1.4.1
mypy-extensions 1.0.0
nest-asyncio 1.5.6
numpy 1.25.2
opencv-python 4.7.0.72
openpyxl 3.1.1
packaging 23.0
pandas 2.0.3
parso 0.8.3
pathspec 0.11.1
pefile 2023.2.7
pickleshare 0.7.5
Pillow 9.4.0
pip 23.3.1
platformdirs 3.1.0
pluggy 1.2.0
prompt-toolkit 3.0.38
psutil 5.9.6
pure-eval 0.2.2
pyarrow 14.0.1
pycparser 2.21
pyflakes 3.0.1
pygfx 0.1.13
Pygments 2.14.0
pyinstaller 5.13.2
pyinstaller-hooks-contrib 2023.0
pylinalg 0.4.1
pylint 2.17.4
pylint-venv 3.0.2
pylsp-mypy 0.6.7
pyodbc 5.0.1
pyogrio 0.6.0
pyparsing 3.0.9
pyproj 3.4.1
PyQt6 6.5.2
PyQt6-Qt6 6.5.0
PyQt6-sip 13.4.1
pyqtgraph 0.13.3
pyshp 2.3.1
python-dateutil 2.8.2
python-lsp-jsonrpc 1.0.0
python-lsp-server 1.7.4
pytz 2022.7.1
pywin32 305
pywin32-ctypes 0.2.2
pyzmq 25.0.0
QtPy 2.3.1
rasterio 1.3.9
requests 2.28.2
scipy 1.11.2
setuptools 65.5.0
shapely 2.0.2
six 1.16.0
snuggs 1.4.7
spyder-kernels 2.5.0
stack-data 0.6.2
superqt 0.4.1
tomlkit 0.11.8
tornado 6.2
tqdm 4.66.1
traitlets 5.9.0
typing_extensions 4.6.3
tzdata 2023.3
uharfbuzz 0.37.0
ujson 5.8.0
urllib3 1.26.15
wcwidth 0.2.6
wgpu 0.9.4
wrapt 1.15.0
XlsxWriter 3.0.8
Previously Working -> Loaded snapshot:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (17 by maintainers)
@almarklein Hi I think you forgot to point to the line. I found it here:
https://github.com/pygfx/pygfx/blob/c64d4d83c058829f4b0a440791a3215ff0406a33/pygfx/renderers/wgpu/engine/shared.py#L77-L80
yep increasing the limit helped. I could load a mesh with 54 million nodes 😃
Ah, I totally forgot about that trick (using nans to break a line in pieces). We should (at some point) include docs on topics like this. E.g. the different ways to draw a collection of lines, and their advantages.
BTW, you can call
gfx.print_wgpu_report()to see the maximum allowed limits for your adapter.I can see in the WebGPU spec and in the docs/source for wgpu-core that the default limit for
max_buffer_sizeis256 << 20 == 2**28 == 268435456.Apparently this was previously higher, or it was not enforced yet, in previous functions.
You can a try editing the pygfx source for the moment: https://github.com/pygfx/pygfx/blob/5ba70b8021ddbc3c35bad3afdbd9e26de6ab27d1/pygfx/renderers/wgpu/_shared.py#L56-L58
You can add
"max_buffer_size": 2**30torequired_limitsto set the limit to 1GiB instead of 256MiB.Next up would to see how we can provide API to set these limits …