spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Doc.vector and Doc.vector_norm not working with GPU

Open emiguevara opened this issue 7 years ago • 1 comments

How to reproduce the behaviour

virtualenv --python=python3.6 env
source env/bin/activate
pip install --no-cache-dir spacy[cuda90] jupyter
python -m spacy download en_core_web_lg
import spacy
spacy.require_gpu()
import en_core_web_lg
nlp = en_core_web_lg.load()

txt = (
    'A deadly cyclone that struck Mozambique and other countries in southern Africa '
    'has nearly obliterated the worst-affected areas, flooding vast stretches of land, '
    'destroying roads and dams, and cutting off victims from help. '
    'The cyclone, called Idai, has affected more than 1.5 million people, '
    'with a death toll now in the dozens but feared to be far higher. '
    'The storm destroyed “90 percent” of Beira, a city of about a half-million '
    'people that is Mozambique’s fourth largest and faces the Indian Ocean, the '
    'International Federation of Red Cross and Red Crescent Societies said on Monday.'
)
doc = nlp(txt)

print(doc.has_vector)
print(doc.vector)

True
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-93c3a0ab48a5> in <module>
      1 print(doc.has_vector)
----> 2 print(doc.vector)

doc.pyx in __iter__()
cupy/core/core.pyx in cupy.core.core.ndarray.__add__()
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'>
print(doc.vector_norm)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-1ca711652528> in <module>
----> 1 print(doc.vector_norm)
doc.pyx in spacy.tokens.doc.Doc.vector_norm.__get__()
doc.pyx in __iter__()
cupy/core/core.pyx in cupy.core.core.ndarray.__add__()
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'>

This is most probably related to #3348 and #3412. Maybe the fix in #3362 was not enough.

NB: other instances of .vector seem to be working fine: for example, Token.vector and Ent.vector

Your Environment

  • spaCy version: 2.1.0
  • Platform: Linux-4.15.0-46-generic-x86_64-with-Ubuntu-18.04-bionic
  • Python version: 3.6.7
  • Environment Information: Cuda 9.0, Cudnn 7.5.0

emiguevara avatar Mar 19 '19 15:03 emiguevara

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[bot] avatar Apr 19 '19 11:04 lock[bot]