SWIFTSIM / swiftsimio

Python library for reading SWIFT data. Uses unyt and h5py.
GNU Lesser General Public License v3.0
18 stars 13 forks source link

swiftsimio/visualisation/projection_backends/gpu.py , numba/cuda version issues #187

Open Will-McD opened 8 months ago

Will-McD commented 8 months ago

Using: Swiftsimio 7.0.0 Numba 0.58.0

from numba import jit
from swiftsimio import mask as sw_mask

There is an instant error from numba/cuda and swiftsimio/visualisation/projection_backends/gpu

The final lines of the error messages are: numba.cuda.cudadrv.driver.CudaAPIError: [2] Call to cuDevicePrimaryCtxRetain results in CUDA_ERROR_OUT_OF_MEMORY raise CudaAPIError(retcode, msg) numba.cuda.cudadrv.driver.CudaAPIError: [2] Call to cuDevicePrimaryCtxRetain results in CUDA_ERROR_OUT_OF_MEMORY

MatthieuSchaller commented 7 months ago

Which machine is this on?

MatthieuSchaller commented 7 months ago

@Will-McD ?

Will-McD commented 7 months ago

Which machine is this on?

I was able to produce this on Cosma8a and 8b, have not tried on any of the other cosma machines. But I have not had this error show up on any of the local machines

JBorrow commented 6 months ago

Are you sure this is a swiftsimio problem and not a numba problem?

Will-McD commented 6 months ago

Are you sure this is a swiftsimio problem and not a numba problem?

I think the issue is within swiftsimio. When I replace swiftsimio with astropy or my own "swiftsimio-like" visualisation functions that are essentially just the functions from swiftsimio without the dependancies on all the packages that swiftsimio has, but keep numba I have had no problems.

JBorrow commented 6 months ago

Can you make appropriate changes to optional_packages.py and submit it as a PR? I would really appreciate it. Looks like we need to guard against some other CUDA errors.

# Numba/CUDA
try:
    from numba.cuda.cudadrv.error import CudaSupportError

    try:
        import numba.cuda.cudadrv.driver as drv
        from numba import cuda
        from numba.cuda import jit as cuda_jit

        try:
            CUDA_AVAILABLE = cuda.is_available()
        except AttributeError:
            # Backwards compatibility with older versions
            # Check for the driver

            d = drv.Driver()
            d.initialize()

            CUDA_AVAILABLE = True

    except CudaSupportError:
        CUDA_AVAILABLE = False

except (ImportError, ModuleNotFoundError):
    # Mock the CudaSupportError so that we can raise it in cases
    # where we don't have numba installed.

    class CudaSupportError(Exception):
        def __init__(self, message):
            self.message = message

    CUDA_AVAILABLE = False
MatthieuSchaller commented 5 months ago

@Will-McD still an issue?