From dd84f7d35e76efbcf5e5f08b7955adee95af13c0 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Mon, 3 Jun 2024 13:09:40 +0200 Subject: [PATCH] touchup: show process name in multiprocess assert --- tinygrad/device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tinygrad/device.py b/tinygrad/device.py index 27d33cf676..8dfe5b9599 100644 --- a/tinygrad/device.py +++ b/tinygrad/device.py @@ -20,7 +20,8 @@ class _Device: @functools.lru_cache(maxsize=None) # this class is a singleton, pylint: disable=method-cache-max-size-none def __get_canonicalized_item(self, ix:str) -> Compiled: if DEBUG >= 1: print(f"opening device {ix} from pid:{os.getpid()}") - assert multiprocessing.current_process().name == "MainProcess" or ix.split(":")[0] in ["DISK", "NPY"], f"can only open device {ix} from parent" + assert ((cpn:=multiprocessing.current_process().name) == "MainProcess") or ix.split(":")[0] in ["DISK", "NPY"], \ + f"can only open device {ix} from parent, not {cpn}" x = ix.split(":")[0].upper() return [cls for cname, cls in inspect.getmembers(importlib.import_module(f'tinygrad.runtime.ops_{x.lower()}')) if (cname.lower() == x.lower() + "device") and x in self._devices][0](ix) # noqa: E501 @functools.cached_property