spaCy: TypeError: Only cupy arrays can be concatenated (Training on GPU)

Training the textcat on GPU, gives the following error. Looks like to_array() doesn’t handle CuPy arrays.

$ python scripts/train_textcat.py
Created blank 'en' model
Loading IMDB data...
Using 2000 examples (1600 training, 400 evaluation)
Training the model...
LOSS      P       R       F
Traceback (most recent call last):
  File "scripts/train_textcat.py", line 133, in <module>
    plac.call(main)
  File "/home/motoki/aes/lib/python3.6/site-packages/plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "/home/motoki/aes/lib/python3.6/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "scripts/train_textcat.py", line 68, in main
    losses=losses)
  File "/home/motoki/aes/lib/python3.6/site-packages/spacy/language.py", line 407, in update
    proc.update(docs, golds, drop=drop, sgd=get_grads, losses=losses)
  File "pipeline.pyx", line 817, in spacy.pipeline.TextCategorizer.update
  File "/home/motoki/aes/lib/python3.6/site-packages/thinc/api.py", line 61, in begin_update
    X, inc_layer_grad = layer.begin_update(X, drop=drop)
  File "/home/motoki/aes/lib/python3.6/site-packages/thinc/api.py", line 176, in begin_update
    values = [fwd(X, *a, **k) for fwd in forward]
  File "/home/motoki/aes/lib/python3.6/site-packages/thinc/api.py", line 176, in <listcomp>
    values = [fwd(X, *a, **k) for fwd in forward]
  File "/home/motoki/aes/lib/python3.6/site-packages/thinc/api.py", line 258, in wrap
    output = func(*args, **kwargs)
  File "/home/motoki/aes/lib/python3.6/site-packages/thinc/api.py", line 61, in begin_update
    X, inc_layer_grad = layer.begin_update(X, drop=drop)
  File "/home/motoki/aes/lib/python3.6/site-packages/spacy/_ml.py", line 101, in _preprocess_doc
    keys = ops.xp.concatenate(keys)
  File "/home/motoki/aes/lib/python3.6/site-packages/cupy/manipulation/join.py", line 49, in concatenate
    return core.concatenate_method(tup, axis)
  File "cupy/core/core.pyx", line 2410, in cupy.core.core.concatenate_method
  File "cupy/core/core.pyx", line 2422, in cupy.core.core.concatenate_method
TypeError: Only cupy arrays can be concatenated

Your Environment

Info about spaCy

  • spaCy version: 2.0.5
  • Platform: Linux-4.10.0-42-generic-x86_64-with-Ubuntu-16.04-xenial
  • Python version: 3.6.4
  • Models: en_core_web_sm
  • thinc 6.10.1
  • cupy 2.2.0
  • Nvidia build version 387.34
  • CUDA version 8.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (1 by maintainers)

Commits related to this issue

Most upvoted comments

It appears to be the issue has gone, but i see that even though you set the flag to use gpu it does not use it. Not sure what is wrong.

I think it was fixed in the latest version