explosion / explosion/spaCy

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

Open
#13,980 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
33.9k
Forks
4.7k
Avg merge
3m
Merged PRs (30d)
1

Description

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:

```python
# /// 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.