Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpaCy 3.8.2 CUDA extras are not compatible with numpy 2.0 #13681

Open
CptCaptain opened this issue Oct 30, 2024 · 2 comments
Open

SpaCy 3.8.2 CUDA extras are not compatible with numpy 2.0 #13681

CptCaptain opened this issue Oct 30, 2024 · 2 comments

Comments

@CptCaptain
Copy link

We wanted to use GPUs for spacy after recently upgrading to spacy v3.8, but this was impossible due to conflicting requirements. The spacy[cudaXXX] still depend on cupy < 13.0.0, which is incompatible with numpy 2.0. Support for this has been added in cupy 13.2 back in june.

How to reproduce the behaviour

Try to install spacy[cuda12x]==3.8.2.

Details

ERROR: Cannot install spacy and spacy[cuda12x]==3.8.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    spacy 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    spacy[cuda12x] 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    cupy-cuda12x 11.5.0 depends on numpy<1.26 and >=1.20
    thinc 8.3.2 depends on numpy<2.1.0 and >=2.0.0; python_version >= "3.9"
    spacy 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    spacy[cuda12x] 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    cupy-cuda12x 11.5.0 depends on numpy<1.26 and >=1.20
    thinc 8.3.1 depends on numpy<2.1.0 and >=2.0.0; python_version >= "3.9"
    spacy 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    spacy[cuda12x] 3.8.2 depends on numpy>=1.19.0; python_version >= "3.9"
    cupy-cuda12x 11.5.0 depends on numpy<1.26 and >=1.20
    thinc 8.3.0 depends on numpy<2.1.0 and >=2.0.0; python_version >= "3.9"

Your Environment

  • Operating System: Ubuntu
  • Python Version Used: 3.10
  • spaCy Version Used: 3.8.2 (failed to install)
  • Environment Information:
@lsmith77
Copy link

lsmith77 commented Nov 6, 2024

see also #13669

@Niket420
Copy link

Niket420 commented Nov 9, 2024

This is a common compatibility issue due to version conflicts between spaCy, CuPy, and NumPy. Here are a few approaches you could try to resolve the issue:

  1. Downgrade NumPy Temporarily

    • You could try installing an earlier version of NumPy (below 2.0) that is compatible with CuPy < 13.0.0. For example:

pip install numpy<2.0

•	Then, install spaCy with the compatible CUDA version:

pip install "spacy[cuda113]" # Replace 113 with the correct version for your CUDA toolkit

•	Note: This may not be sustainable in the long term, especially if you need NumPy 2.0 for other dependencies. This is a temporary workaround until spaCy adds support for CuPy >= 13.2.
  1. Use CuPy 13.2+ Independently of spaCy

    • Install CuPy 13.2 or later directly, bypassing the version constraint by not using spacy[cudaXXX]:

pip install cupy-cuda113 # Replace 113 with your CUDA version
pip install spacy

•	Then, configure spaCy manually to use the installed CuPy version.

import spacy
spacy.require_gpu()

•	This way, spaCy uses the existing CuPy installation without enforcing its specific version requirements.
  1. Use a Conda Environment

    • Conda has more flexibility in handling dependencies and might offer versions that work well together:

conda create -n spacy-gpu-env python=3.10
conda activate spacy-gpu-env
conda install -c conda-forge spacy cupy numpy=1.24

•	Check compatibility as you go. After setting up the environment, test spaCy with require_gpu() as shown above.
  1. Monitor for Updates and SpaCy Compatibility Patches

    • Since support for NumPy 2.0 in CuPy 13.2 was added recently, spaCy may soon include support for CuPy >= 13.2 in future releases. It could be beneficial to keep an eye on upcoming spaCy releases or GitHub issues related to GPU support, as they may incorporate fixes for this conflict.

One of these workarounds should help you proceed with GPU support on spaCy. Let me know if you need further guidance on any of these steps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants