{"library":"numba-cuda","title":"Numba CUDA Target","description":"Numba-cuda provides a CUDA target for the Numba Python JIT compiler, enabling Python functions to be compiled and executed on NVIDIA GPUs. It allows users to write custom GPU kernels and device functions directly in a subset of Python. The library, currently at version 0.30.0, is actively developed by NVIDIA, with its release cycle now decoupled from the main Numba project to facilitate more frequent updates and new feature development.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install numba-cuda"],"cli":null},"imports":["from numba import cuda"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom numba import cuda\nimport os\n\n# Check for CUDA availability (runtime dependency)\nif not cuda.is_available():\n    print(\"CUDA is not available. Please ensure you have an NVIDIA GPU and CUDA drivers installed.\")\n    exit()\n\n# Define a CUDA kernel\n@cuda.jit\ndef add_vectors(x, y, out):\n    idx = cuda.grid(1)\n    if idx < len(out):\n        out[idx] = x[idx] + y[idx]\n\n# Host-side code\nN = 1000000\nx_host = np.arange(N, dtype=np.float32)\ny_host = np.arange(N, dtype=np.float32)\nout_host = np.empty_like(x_host)\n\n# Allocate memory on the device and copy data\nx_device = cuda.to_device(x_host)\ny_device = cuda.to_device(y_host)\nout_device = cuda.device_array_like(out_host)\n\n# Configure the kernel launch\nthreadsperblock = 256\nblockspergrid = (N + (threadsperblock - 1)) // threadsperblock\n\n# Launch the kernel\nadd_vectors[blockspergrid, threadsperblock](x_device, y_device, out_device)\n\n# Copy the result back to the host\nout_device.copy_to_host(out_host)\n\n# Verify the result\nexpected_out = x_host + y_host\nassert np.allclose(out_host, expected_out)\nprint(\"Vector addition on GPU successful!\")","lang":"python","description":"This quickstart demonstrates a basic vector addition using a Numba CUDA kernel. It covers defining a kernel with `@cuda.jit`, allocating and transferring data between host (CPU) and device (GPU) memory, configuring and launching the kernel, and copying results back to the host. Ensure you have a CUDA-enabled GPU and appropriate drivers installed.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.30.2","pypi_latest":"0.30.2","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":8.3,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":0.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"numba-cuda","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8.3,"import_time_s":null,"mem_mb":null,"disk_size":"327M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"numba-cuda","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8,"import_time_s":null,"mem_mb":null,"disk_size":"346M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":0.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"numba-cuda","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8.3,"import_time_s":null,"mem_mb":null,"disk_size":"332M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"numba-cuda","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8.4,"import_time_s":null,"mem_mb":null,"disk_size":"331M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":0.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"numba-cuda","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":9.4,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}