2024-08-08 01:46:24 +08:00
|
|
|
import unittest
|
|
|
|
from tinygrad import Device
|
2024-08-08 13:19:29 +08:00
|
|
|
from tinygrad.helpers import CI
|
2024-08-08 01:46:24 +08:00
|
|
|
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)")
|
2024-08-08 01:46:24 +08:00
|
|
|
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"
|