-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy path_gpu_info.py
More file actions
66 lines (50 loc) · 1.78 KB
/
_gpu_info.py
File metadata and controls
66 lines (50 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pathlib import Path
from wgpu.backends.wgpu_native import enumerate_adapters
from wgpu.utils import get_default_device
try:
ip = get_ipython()
from ipywidgets import Image
from wgpu.gui.jupyter import JupyterWgpuCanvas
except (NameError, ModuleNotFoundError, ImportError):
NOTEBOOK = False
else:
from IPython.display import display
if ip.has_trait("kernel") and (JupyterWgpuCanvas is not False):
NOTEBOOK = True
else:
NOTEBOOK = False
def _notebook_print_banner():
if NOTEBOOK is False:
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)