GPU selection

Demonstrate how a specific GPU can be selected, or how a GPU can be selected using a power preference.

import wgpu
import pygfx as gfx

# You can express whether you prefer a "high-performance" (default) or "low-power" device.
# Note that the power preference is ignored if select_adapter() is used.

# Get a list of all adapters from wgpu
adapters = wgpu.gpu.enumerate_adapters()

# Show the options
print("Available adapters:")
for a in adapters:

# The best way to select an adapter is highly dependent on the use-case.
# Here we prefer a Geforce GPU, but fallback to the default if its not available.
adapters_geforce = [a for a in adapters if "geforce" in a.summary.lower()]
if adapters_geforce:

# Draw a cube
cube = gfx.Mesh(
    gfx.box_geometry(200, 200, 200),

if __name__ == "__main__":
    disp = gfx.Display()

    # Show what adapter was selected

Gallery generated by Sphinx-Gallery