From e83905696eed289c407db550833abf23f9740be3 Mon Sep 17 00:00:00 2001 From: Ahmed Harmouche Date: Thu, 13 Feb 2025 22:30:20 +0100 Subject: [PATCH] Show install instructions when dawn library is missing (#9059) * Show install instructions when dawn library is missing * Handle missing dawn in ops_webgpu * Simplify * Solve f-string backlash error --- tinygrad/runtime/ops_webgpu.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tinygrad/runtime/ops_webgpu.py b/tinygrad/runtime/ops_webgpu.py index 357680081a..3f83f93ef0 100644 --- a/tinygrad/runtime/ops_webgpu.py +++ b/tinygrad/runtime/ops_webgpu.py @@ -1,12 +1,16 @@ import functools, struct from tinygrad.device import Compiled, Allocator, Compiler from tinygrad.renderer.wgsl import WGSLRenderer -from tinygrad.helpers import round_up +from tinygrad.helpers import round_up, OSX from tinygrad.runtime.autogen import webgpu from typing import List, Any import ctypes -instance = webgpu.wgpuCreateInstance(webgpu.WGPUInstanceDescriptor(features = webgpu.WGPUInstanceFeatures(timedWaitAnyEnable = True))) +try: + instance = webgpu.wgpuCreateInstance(webgpu.WGPUInstanceDescriptor(features = webgpu.WGPUInstanceFeatures(timedWaitAnyEnable = True))) +except AttributeError: + raise RuntimeError("Cannot find dawn library. Install it with: " + ("brew tap wpmed92/dawn && brew install dawn" if OSX else + "sudo curl -L https://github.com/wpmed92/pydawn/releases/download/v0.1.6/libwebgpu_dawn.so -o /usr/lib/libwebgpu_dawn.so")) def to_c_string(_str): return ctypes.create_string_buffer(_str.encode('utf-8'))