tinygrad/test/test_ocl.py

14 lines
527 B
Python
Raw Normal View History

import unittest
from tinygrad import Device
2024-08-08 13:19:29 +08:00
from tinygrad.helpers import CI
from tinygrad.runtime.ops_gpu import CLDevice, CLAllocator
2024-08-08 13:19:29 +08:00
@unittest.skipUnless(Device.DEFAULT in ["GPU"] and not CI, "Runs only on OpenCL (GPU)")
class TestOCLOOM(unittest.TestCase):
def test_opencl_oom(self):
with self.assertRaises(RuntimeError) as err:
allocator = CLAllocator(CLDevice())
for i in range(1_000_000):
allocator.alloc(1_000_000_000)
assert str(err.exception) == "OpenCL Error -6: CL_OUT_OF_HOST_MEMORY"