Spacy does not return vector if GPU is enabled
See original GitHub issueI’m using a GPU-enabled Google Colab notebook.
After installing the requisite libraries and models
!pip install spacy[cuda100]~=2.2 scispacy~=0.2.4
!pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.4/en_core_sci_lg-0.2.4.tar.gz
import spacy
spacy.prefer_gpu()
nlp = spacy.load("en_core_sci_lg")
text = """
Myeloid derived suppressor cells (MDSC) are immature
myeloid cells with immunosuppressive activity.
They accumulate in tumor-bearing mice and humans
with different types of cancer, including hepatocellular
carcinoma (HCC).
"""
doc = nlp(text)
Running
doc.ents
produces
(Myeloid,
suppressor cells,
MDSC,
immature,
myeloid cells,
immunosuppressive activity,
accumulate,
tumor-bearing mice,
humans,
cancer,
hepatocellular
carcinoma,
HCC)
as expected, but
doc.vector
produces this error:
TypeError Traceback (most recent call last)
<ipython-input-19-40a48203c66b> in <module>()
----> 1 doc.vector
doc.pyx in __iter__()
cupy/core/core.pyx in cupy.core.core.ndarray.__array_ufunc__()
cupy/core/_kernel.pyx in cupy.core._kernel.ufunc.__call__()
cupy/core/_kernel.pyx in cupy.core._kernel._preprocess_args()
TypeError: Unsupported type <class 'numpy.ndarray'>
Commenting out
spacy.prefer_gpu()
solves the issue. This means that getting token vectors will not be able when the GPU is enabled?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Vectors · spaCy API Documentation
Vectors data is kept in the Vectors.data attribute, which should be an instance of numpy.ndarray (for CPU vectors) or cupy.ndarray (for GPU vectors)....
Read more >SpaCy's most_similar() function returns error on GPU
I'm trying to evaluate performance of most_similar ...
Read more >spaczz - PyPI
Spaczz expects token matches returned in order of ascending match start, then descending match length. However, spaCy's Matcher does not return matches in ......
Read more >Turbo-charge your spaCy NLP pipeline | Inverse Entropy
Since we will not be doing any specialized tasks such as dependency parsing ... these components are disabled when loading the spaCy model....
Read more >SPACY v3: Custom trainable relation extraction component
spaCy v3.0 features new transformer-based pipelines tha... ... try restarting your device. Your browser can't play this video.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @danielkingai2,
I also see your problem.
For full documentation’s sake:
produces
Relevant package versions:
Closing this for now as it seems it’s a spacy issue and not scispacy’s.
Any update on this?