diff --git a/numba_cuda/numba/cuda/api.py b/numba_cuda/numba/cuda/api.py index 164a1ccba..9fe8cd7ea 100644 --- a/numba_cuda/numba/cuda/api.py +++ b/numba_cuda/numba/cuda/api.py @@ -8,6 +8,7 @@ import contextlib import os +from numba.cuda.cudadrv import drvapi import numpy as np from .cudadrv import devicearray, devices, driver @@ -47,7 +48,11 @@ def from_cuda_array_interface(desc, owner=None, sync=True): ) size = driver.memory_size_from_info(shape, strides, dtype.itemsize) - devptr = driver.get_devptr_for_active_ctx(desc["data"][0]) + if config.CUDA_USE_NVIDIA_BINDING: + cudevptr_class = driver.binding.CUdeviceptr + else: + cudevptr_class = drvapi.cu_device_ptr + devptr = cudevptr_class(desc["data"][0]) data = driver.MemoryPointer( current_context(), devptr, size=size, owner=owner ) diff --git a/numba_cuda/numba/cuda/cudadrv/devicearray.py b/numba_cuda/numba/cuda/cudadrv/devicearray.py index fa775898e..0f496b620 100644 --- a/numba_cuda/numba/cuda/cudadrv/devicearray.py +++ b/numba_cuda/numba/cuda/cudadrv/devicearray.py @@ -105,13 +105,11 @@ def __init__(self, shape, strides, dtype, stream=0, gpu_data=None): self.size = int(functools.reduce(operator.mul, self.shape, 1)) # prepare gpu memory if self.size > 0: + self.alloc_size = _driver.memory_size_from_info( + self.shape, self.strides, self.dtype.itemsize + ) if gpu_data is None: - self.alloc_size = _driver.memory_size_from_info( - self.shape, self.strides, self.dtype.itemsize - ) gpu_data = devices.get_context().memalloc(self.alloc_size) - else: - self.alloc_size = _driver.device_memory_size(gpu_data) else: # Make NULL pointer for empty allocation if _driver.USE_NV_BINDING: