From ab2d4d8d29e799c844f19101adf83aa70cd1d5af Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:22:07 -0500 Subject: [PATCH] Fix cl import in the copy_speed test and cifar example (#2586) * fix CL import * update test to only run on GPU * update hlb_cifar too --- examples/hlb_cifar10.py | 4 ++-- test/test_copy_speed.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/hlb_cifar10.py b/examples/hlb_cifar10.py index 8ec95cdf..7079de63 100644 --- a/examples/hlb_cifar10.py +++ b/examples/hlb_cifar10.py @@ -430,8 +430,8 @@ if __name__ == "__main__": from tinygrad.runtime.ops_hip import HIP devices = [f"hip:{i}" for i in range(HIP.device_count)] else: - from tinygrad.runtime.ops_gpu import CL - devices = [f"gpu:{i}" for i in range(len(CL.devices))] + from tinygrad.runtime.ops_gpu import CLDevice + devices = [f"gpu:{i}" for i in range(len(CLDevice.device_ids))] world_size = len(devices) # ensure that the batch size is divisible by the number of devices diff --git a/test/test_copy_speed.py b/test/test_copy_speed.py index bb2f16f5..bd271535 100644 --- a/test/test_copy_speed.py +++ b/test/test_copy_speed.py @@ -51,9 +51,10 @@ class TestCopySpeed(unittest.TestCase): t.to('cpu').realize() @unittest.skipIf(CI, "CI doesn't have 6 GPUs") + @unittest.skipIf(Device.DEFAULT != "GPU", "only test this on GPU") def testCopyCPUto6GPUs(self): - from tinygrad.runtime.ops_gpu import CL - if len(CL.devices) != 6: raise unittest.SkipTest("computer doesn't have 6 GPUs") + from tinygrad.runtime.ops_gpu import CLDevice + if len(CLDevice.device_ids) != 6: raise unittest.SkipTest("computer doesn't have 6 GPUs") t = Tensor.rand(N, N, device="cpu").realize() print(f"buffer: {t.nbytes()*1e-9:.2f} GB") for _ in range(3): @@ -64,4 +65,4 @@ class TestCopySpeed(unittest.TestCase): Device["gpu"].synchronize() if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()