Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion numba_cuda/numba/cuda/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import contextlib
import os

from numba.cuda.cudadrv import drvapi
import numpy as np

from .cudadrv import devicearray, devices, driver
Expand Down Expand Up @@ -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
)
Expand Down
8 changes: 3 additions & 5 deletions numba_cuda/numba/cuda/cudadrv/devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down