I have a sample code that illustrates the issue:
import numpy as np
from numba import cuda, types
import configs
def main():
arr = np.empty(0, dtype=np.uint8)
stream = cuda.stream()
d_arr = cuda.to_device(arr, stream=stream)
kernel[configs.BLOCK_COUNT, configs.THREAD_COUNT, stream](d_arr)
@cuda.jit(types.void(
types.Array(types.uint8, 1, 'C'),
), debug=configs.CUDA_DEBUG)
def kernel(d_arr):
arr = cuda.const.array_like(d_arr)
if __name__ == "__main__":
main()
When I run this code with cuda-memcheck, I get:
numba.errors.ConstantInferenceError: Failed in nopython mode pipeline (step: nopython rewrites)
Constant inference not possible for: arg(0, name=d_arr)
Which seems to indicate that array I passed in was not a constant so it could not be copied to constant memory - is that the case? If so, how can I copy to constant memory an array that was given to a kernel as input?