Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
recursive-include fastplotlib/utils/colormaps/ *
include fastplotlib/VERSION
recursive-include fastplotlib/assets/ *

12 changes: 12 additions & 0 deletions fastplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .layouts import Plot, GridPlot
from .graphics import *
from .graphics.selectors import *
from .legends import *
Comment thread
kushalkolar marked this conversation as resolved.
Outdated
from .utils import print_adapter_info

from wgpu.gui.auto import run

Expand All @@ -13,6 +15,16 @@
else:
from .widgets import ImageWidget

from wgpu.backends.wgpu_native import enumerate_adapters

adapters = [a.request_adapter_info() for a in enumerate_adapters()]

if len(adapters) < 1:
raise IndexError(
"No WGPU adapters found, fastplotlib will not work."
)

print_adapter_info()

with open(Path(__file__).parent.joinpath("VERSION"), "r") as f:
__version__ = f.read().split("\n")[0]
Expand Down
3 changes: 3 additions & 0 deletions fastplotlib/assets/fastplotlib_face_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions fastplotlib/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .functions import *
from ._gpu_info import print_adapter_info
68 changes: 68 additions & 0 deletions fastplotlib/utils/_gpu_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from pathlib import Path

from wgpu.backends.wgpu_native import enumerate_adapters
from wgpu.utils import get_default_device

try:
from wgpu.gui.jupyter import JupyterWgpuCanvas
except ImportError:
JupyterWgpuCanvas = False

try:
from IPython.display import display
from ipywidgets import Image
except NameError:
pass


def print_adapter_info():
try:
ip = get_ipython()
if not (ip.has_trait("kernel") and JupyterWgpuCanvas is not False):
return
except NameError:
return

logo_path = Path(__file__).parent.parent.joinpath("assets", "fastplotlib_face_logo.png")

with open(logo_path, "rb") as f:
logo_data = f.read()

image = Image(
value=logo_data,
format="png",
width=300,
height=55
)

display(image)

# print logo and adapter info
adapters = [a for a in enumerate_adapters()]
adapters_info = [a.request_adapter_info() for a in adapters]

ix_default = adapters_info.index(get_default_device().adapter.request_adapter_info())

if len(adapters) > 0:
print("Available devices:")

for ix, adapter in enumerate(adapters_info):
atype = adapter["adapter_type"]
backend = adapter["backend_type"]
driver = adapter["description"]
device = adapter["device"]

if atype == "DiscreteGPU" and backend != "OpenGL":
charactor = chr(0x2705)
elif atype == "IntegratedGPU" and backend != "OpenGL":
charactor = chr(0x0001FBC4)
else:
charactor = chr(0x2757)

if ix == ix_default:
default = " (default) "
else:
default = " "

output_str = f"{charactor}{default}| {device} | {atype} | {backend} | {driver}"
print(output_str)