fastplotlib / fastplotlib

Next-gen fast plotting library running on WGPU using the pygfx rendering engine
https://fastplotlib.readthedocs.io/
Apache License 2.0
342 stars 33 forks source link

Select gpu #491

Closed kushalkolar closed 1 month ago

kushalkolar commented 1 month ago

basically wrapper for https://github.com/pygfx/pygfx/pull/709 and https://github.com/pygfx/wgpu-py/pull/481

Adds a fastplotlib.utils.gpu module, and exposes enumerate_adapters, select_adapter, and print_wgpu_report at top level.

Example:

import fastplotlib as fpl

fpl.select_adapter(fpl.enumerate_adapters()[2])

Also added corresponding info to docs: https://fastplotlib--491.org.readthedocs.build/en/491/user_guide/gpu.html#gpu-info

kushalkolar commented 1 month ago

Do you think it makes sense to expose this as a top level import? I don't think there's a use case for many more gpu related functions to create a "fpl.gpu" namespace.

almarklein commented 1 month ago

Do you think it makes sense to expose this as a top level import? I don't think there's a use case for many more gpu related functions to create a "fpl.gpu" namespace.

In pygfx we deliberately do not make it part of the toplevel namespace, because its not something most users need. Maybe more important, it makes code less portable. But in pygfx we already had a namespace for advanced wgou-specific stuff (gfx.renderers.wgpu). Perhaps introducing a namespace just for this (in fpl) is a bit overkill ...

Maybe put differently ... if fpl is currently a single namespace, I'd just put it in there, I think.

kushalkolar commented 1 month ago

Thanks! I like having your input since you're much much experienced in API design 😄