Skip to content

feature request: Add spacy support cupy>13 (CUDA 13) #13980

Description

@KennethEnevoldsen

Currently, spacy does not (officially) support cupy>=13, which also means that I can't use spacy with cuda>13 which e.g. also prevents usage on blackwell GPUs (B200). At least it is not clear in the docs.

However I can circumvent it with the following fix:

# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "spacy",
#     "cupy-cuda13x[ctk]",
#     "en-core-web-sm",
# ]
#
# [tool.uv.sources]
# en-core-web-sm = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl" }
# ///
"""Minimal repro: spaCy on a CUDA 13 / Blackwell GPU (e.g. B200, sm_100).

Run with:  uv run test_spacy.py
"""

import cupy

# Sanity: CuPy sees the GPU
print("CuPy:", cupy.__version__, "| device:",
      cupy.cuda.runtime.getDeviceProperties(0)["name"].decode())

import spacy

print("Require gpu:", spacy.require_gpu())

# Run a real pipeline on the GPU
nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying a U.K. startup for $1 billion.")
print("Entities:", [(ent.text, ent.label_) for ent in doc.ents])

Which reproduces the expected:

CuPy: 14.1.1 | device: NVIDIA B200 MIG 1g.23gb
Require gpu: True
Entities: [('Apple', 'ORG'), ('U.K.', 'GPE'), ('$1 billion', 'MONEY')]

This is not entirely clear from the docs that this is possible, where the most recent version seems to be pip install 'spacy[cuda12x]' (similar also the case if you look at the setup.cfg). I suspect the fix is to add a cuda13x extra and raise the cupy<13 cap.

There might be issues that I have not discovered with this approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions