cupy runtime compilation failed

123 Views Asked by At

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)

2

There are 2 best solutions below

0
Jing On

I do two ways that both works:

  1. add J = cp.array(J, dtype=cp.complex128)
  2. switch NVIDIA GeForce GTX 1080 Ti to another gpu NVIDIA GeForce RTX 4090
0
user2561747 On

I also get this error on a 1080 Ti running cuda version 12.3 and cupy-cuda12x-13.0.0. By changing versions to cupy-cuda12x-12.3.0, it works like a charm (and other code that didn't error but took forever to compile now works like a charm!).