Skip to content

Commit 2f23604

Browse files
Disable SVM on Nvidia CL when running pytest (#200)
* disable SVM on Nvidia CL when running pytest * undo previous changes * disable in pytest actx
1 parent 8b4e2f2 commit 2f23604

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

arraycontext/pytest.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,21 @@ def __call__(self):
100100
# On some implementations (notably Intel CPU), holding a reference
101101
# to a queue does not keep the context alive.
102102
ctx, queue = self.get_command_queue()
103+
104+
alloc = None
105+
106+
if queue.device.platform.name == "NVIDIA CUDA":
107+
from pyopencl.tools import ImmediateAllocator
108+
alloc = ImmediateAllocator(queue)
109+
110+
from warnings import warn
111+
warn("Disabling SVM due to memory leak "
112+
"in Nvidia CL when running pytest. "
113+
"See https://github.com/inducer/arraycontext/issues/196")
114+
103115
return self.actx_class(
104116
queue,
117+
allocator=alloc,
105118
force_device_scalars=self.force_device_scalars)
106119

107120
def __str__(self):
@@ -141,7 +154,19 @@ def __call__(self):
141154
# On some implementations (notably Intel CPU), holding a reference
142155
# to a queue does not keep the context alive.
143156
ctx, queue = self.get_command_queue()
144-
return self.actx_class(queue)
157+
158+
alloc = None
159+
160+
if queue.device.platform.name == "NVIDIA CUDA":
161+
from pyopencl.tools import ImmediateAllocator
162+
alloc = ImmediateAllocator(queue)
163+
164+
from warnings import warn
165+
warn("Disabling SVM due to memory leak "
166+
"in Nvidia CL when running pytest. "
167+
"See https://github.com/inducer/arraycontext/issues/196")
168+
169+
return self.actx_class(queue, allocator=alloc)
145170

146171
def __str__(self):
147172
return ("<PytatoPyOpenCLArrayContext for <pyopencl.Device '%s' on '%s'>>" %

0 commit comments

Comments
 (0)