From fca5028d782769b2d92df16d2c5ca579551b0145 Mon Sep 17 00:00:00 2001 From: wozeparrot Date: Thu, 25 May 2023 20:31:29 -0400 Subject: [PATCH] feat: ability to exclude cl devices from being used (#801) --- tinygrad/runtime/ops_gpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinygrad/runtime/ops_gpu.py b/tinygrad/runtime/ops_gpu.py index c4ac38ece7..d129f72d5a 100644 --- a/tinygrad/runtime/ops_gpu.py +++ b/tinygrad/runtime/ops_gpu.py @@ -23,7 +23,7 @@ class _CL: def __init__(self): platforms: List[List[cl.Device]] = [y for y in ([x.get_devices(device_type=cl.device_type.GPU) for x in cl.get_platforms()] + [x.get_devices(device_type=cl.device_type.CPU) for x in cl.get_platforms()]) if len(y)] if DEBUG >= 1: print(f"using {platforms[getenv('CL_PLATFORM', 0)]}") - self.cl_ctx: cl.Context = cl.Context(devices=platforms[getenv('CL_PLATFORM', 0)]) + self.cl_ctx: cl.Context = cl.Context(devices=[x for x in platforms[getenv('CL_PLATFORM', 0)] if x.name not in getenv('CL_EXCLUDE', "").split(",")]) self.cl_queue: List[cl.CommandQueue] = [cl.CommandQueue(self.cl_ctx, device=device, properties=cl.command_queue_properties.PROFILING_ENABLE) for device in self.cl_ctx.devices] def synchronize(self): for q in self.cl_queue: q.finish()