I'm new to cupy and try to learn it.
This following code provides an error using cuda11
import numpy
import cupy
def monte_carlo_gpu(n:int, m:int)-> float:
accum = 0
for i in range(m):
x = cupy.random.random(n, dtype=numpy.float32)
y = cupy.random.random(n, dtype=numpy.float32)
r = cupy.less(x**2 + y**2, 1.0)
accum += cupy.sum(r)/n
return 4.0*accum/m
RuntimeError: Runtime compilation failed
How can I resolve this?
I was waiting for pi value (monte carlo GPU)
I do two ways that both works:
J = cp.array(J, dtype=cp.complex128)