Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.54.1 instead.
Reason given by maintainers: not installable with shap==0.54.0 due to wrongly published wheels

shap-cuda

CUDA-accelerated GPUTreeExplainer backend for shap.

Installing this package registers GPUTreeExplainer with shap via the shap.tree_backends entry-point group; use it through shap.GPUTreeExplainer, not by importing shap_cuda directly.

Build locally from source

Build both shap and shap-cuda from the same checkout: the backend uses SHAP internals and checks that their release versions match. The commands below are for Linux and run from the repository root, not this backend directory.

Prerequisites

  • Python 3.12 or newer; Python 3.13 is used in the examples below.
  • A C++ compiler and Python development headers (on Ubuntu/Debian, install build-essential and the development package for your Python version).
  • The NVIDIA CUDA toolkit, including nvcc. CI builds with CUDA 12.8; the backend currently targets GPU architectures 60, 70, 75, and 80, so use a toolkit that supports those targets.
  • An NVIDIA GPU and a compatible NVIDIA driver to run explanations. Building the extension does not require a physical GPU.

Check that the toolkit and driver are available:

nvcc --version
nvidia-smi

If the toolkit is installed outside your PATH, point the build at it. Adjust this example to your installation:

export PATH=/usr/local/cuda-12.8/bin:$PATH
export CUDACXX=/usr/local/cuda-12.8/bin/nvcc

The build backend installs CMake (3.24 or newer) and its other Python build dependencies in an isolated environment as needed. The separate CUDA backend does not require the old SHAP_ENABLE_CUDA environment variable.

Install with uv

uv venv --python 3.13
source .venv/bin/activate
uv sync --extra cuda

The repository's uv workspace resolves the cuda extra to the local backends/shap-cuda package and builds both packages as editable installs.

Install with pip

Alternatively, create and activate a virtual environment, then explicitly install both local packages:

python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -v -e . -e ./backends/shap-cuda

Using pip install -e '.[cuda]' alone can resolve shap-cuda from a package index instead of this checkout; pip does not use uv's workspace configuration.

Verify and use the backend

Confirm that the compiled extension loads and that SHAP discovers the backend:

python -c "import shap; import shap_cuda._cext_gpu; print(shap.GPUTreeExplainer)"

Importing the extension directly here is a build check. For explanations, use the public SHAP API:

import numpy as np
import shap
from sklearn.tree import DecisionTreeRegressor

X = np.array([[0., 0.], [0., 1.], [1., 0.], [1., 1.]])
model = DecisionTreeRegressor(max_depth=2).fit(X, X[:, 0] + X[:, 1])
explainer = shap.GPUTreeExplainer(model)
values = explainer.shap_values(X)
print(values)

This example also checks that GPU execution works. Importing the package alone does not prove that the CUDA extension was built. In verbose build output, look for CUDA toolkit found, building the _cext_gpu extension. If the extension is missing or the build cannot find nvcc, check CUDACXX and the toolkit installation, then rebuild:

# uv
uv sync --extra cuda --reinstall-package shap-cuda

# Or pip; --no-deps keeps the existing local SHAP installation.
python -m pip install -v --no-cache-dir --force-reinstall --no-deps -e ./backends/shap-cuda

Metadata

Release files for shap-cuda 0.54.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for shap-cuda 0.54.0
File Interpreter ABI Platform
shap_cuda-0.54.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details

Release files / shap_cuda-0.54.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL shap_cuda-0.54.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 3.3 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
a40327f137db88a3f8822cf57209afcef37de73d07804a98faa805d0fd49df72
BLAKE2b-256 checksum
How to use checksums
52d5c99c985110761c93aa928467dade1f9528ff784e9a416430dce1c1aa2eb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.54.1

1 release file

This release

0.54.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page