Skip to content

Commit 3d83295

Browse files
guociinducer
authored andcommitted
refactor for Python 3
1 parent 2200348 commit 3d83295

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/fill_gpu_with_nans.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
free_bytes, total_bytes = cuda.mem_get_info()
77
exp = 10
88
while True:
9-
fill_floats = free_bytes / 4 - (1<<exp)
9+
fill_floats = free_bytes // 4 - (1 << exp)
1010
if fill_floats < 0:
1111
raise RuntimeError("couldn't find allocatable size")
12+
print("alloc", fill_floats)
1213
try:
13-
print("alloc", fill_floats)
1414
ary = gpuarray.empty((fill_floats,), dtype=numpy.float32)
15-
break
16-
except:
15+
except cuda.MemoryError:
1716
pass
17+
else:
18+
break
1819

1920
exp += 1
2021

0 commit comments

Comments
 (0)