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 2.1 bug when running with GPU: 'gpu_ops' is not defined #3437

Closed
01alex opened this issue Mar 19, 2019 · 4 comments
Closed

Spacy 2.1 bug when running with GPU: 'gpu_ops' is not defined #3437

01alex opened this issue Mar 19, 2019 · 4 comments
Labels
bug Bugs and behaviour differing from documentation install Installation issues 🔮 thinc spaCy's machine learning library Thinc upgrade Issues related to upgrading spaCy

Comments

@01alex
Copy link

01alex commented Mar 19, 2019

How to reproduce the behaviour

!pip install -U spacy
!python -m spacy download en

import spacy

gpu = spacy.prefer_gpu()
print('GPU:', gpu)

nlp = spacy.load("en_core_web_sm")

doc = nlp("This is a sentence. This is another sentence.")
for sent in doc.sents:
    print(sent.text)

Output

GPU: True
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-1313493bc47b> in <module>()
      6 nlp = spacy.load("en_core_web_sm")
      7 
----> 8 doc = nlp("This is a sentence. This is another sentence.")
      9 for sent in doc.sents:
     10     print(sent.text)

(...)

ops.pyx in thinc.neural.ops.CupyOps.hash()

NameError: name 'gpu_ops' is not defined

This exact same code worked yesterday with the previous release.

Note

If I do:

!pip uninstall thinc
!pip install thinc==7.0.3

It works correctly:

GPU: True
This is a sentence.
This is another sentence.

Your Environment

  • spaCy version: 2.1.0
  • Platform: Linux-4.14.79+-x86_64-with-Ubuntu-18.04-bionic
  • Python version: 3.6.7
  • Models: en
  • Environment Information: Google Colaboratory (Python 3 Google Compute Engine backend (GPU)), CUDA 10.0
@ines
Copy link
Member

ines commented Mar 19, 2019

Did you install the new version in the same environment as the old one, and did you specify your CUDA version as described here? It's possible that you ended up with stale files or packages in your site-packages, or Thinc didn't correctly pull in the thinc_gpu_ops.

@ines ines added install Installation issues 🔮 thinc spaCy's machine learning library Thinc upgrade Issues related to upgrading spaCy labels Mar 19, 2019
@01alex
Copy link
Author

01alex commented Mar 19, 2019

So I ran two new Python 3 Google Compute Engine backend (GPU).
The first with the default spaCy 2.0.18.

The example:

import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence. This is another sentence.")
for sent in doc.sents:
    print(sent.text)

It works fine. Then I required the gpu after import spacy, it returns true and throws the error.
In another runtime, I started with:

!pip install -U spacy[cuda100]
!python -m spacy download en

The update output:

Installing collected packages: srsly, numpy, wasabi, blis, thinc, spacy
  Found existing installation: numpy 1.14.6
    Uninstalling numpy-1.14.6:
      Successfully uninstalled numpy-1.14.6
  Found existing installation: thinc 6.12.1
    Uninstalling thinc-6.12.1:
      Successfully uninstalled thinc-6.12.1
  Found existing installation: spacy 2.0.18
    Uninstalling spacy-2.0.18:
      Successfully uninstalled spacy-2.0.18
Successfully installed blis-0.2.4 numpy-1.16.2 spacy-2.1.0 srsly-0.0.5 thinc-7.0.4 wasabi-0.1.4

Checked version 2.1.0. Ran the example snippet. It works fine on cpu. Required gpu and got the same error.
It was working fine yesterday with spaCy 2.0.18.

@honnibal honnibal added the bug Bugs and behaviour differing from documentation label Mar 19, 2019
@honnibal
Copy link
Member

Thanks, this was a regression introduced when fixing #3430 .

Thinc v7.0.3 required the thinc_gpu_ops module, which caused problems if CUDA was installed but no GPU was available (or if no compiler was installed).

The fix is to make the thinc_gpu_ops module an extras_require. This was set correctly in Thinc v7.0.4, but I didn't set it in spaCy. Have triggered a build for v2.1.1 to fix this.

@lock
Copy link

lock bot commented Apr 19, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation install Installation issues 🔮 thinc spaCy's machine learning library Thinc upgrade Issues related to upgrading spaCy
Projects
None yet
Development

No branches or pull requests

3 participants