# Error using GPU with an existing model

**URL:** https://support.prodi.gy/t/error-using-gpu-with-an-existing-model/1911
**Category:** Uncategorized
**Tags:** usage, spacy
**Created:** [August 19, 2019, 12:28pm UTC](https://support.prodi.gy/t/error-using-gpu-with-an-existing-model/1911 "2019-08-19T12:28:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aslitoj](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/aslitoj/32/925_2.png) [@aslitoj](https://support.prodi.gy/u/aslitoj)
#### Post date: [August 19, 2019, 12:28pm UTC](https://support.prodi.gy/t/error-using-gpu-with-an-existing-model/1911/1 "2019-08-19T12:28:31Z")

</div>

Hello @ines and @honnibal,  
I tried to train the model using GPU but I couldn't able to run properly with an existing model while there is no problem running it with an empty spaCy model.

Also, when I run locally my train\_new\_entity\_type.py for 3 labels, there isn't any problem but when I tried it with GPU I got this following error:

```python
Loaded model 'en_core_web_lg'
Traceback (most recent call last):
  File "train_new_entity_type.py", line 4603, in <module>
    plac.call(main)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "train_new_entity_type.py", line 4573, in main
    nlp.update(texts, annotations, sgd=optimizer, drop=0.20, losses=losses)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/spacy/language.py", line 449, in update
    proc.update(docs, golds, drop=drop, sgd=get_grads, losses=losses)
  File "nn_parser.pyx", line 423, in spacy.syntax.nn_parser.Parser.update
  File "_parser_model.pyx", line 199, in spacy.syntax._parser_model.ParserModel.begin_update.finish_parser_update
  File "_parser_model.pyx", line 323, in spacy.syntax._parser_model.ParserStepModel.make_updates
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
    gradient = callback(gradient, sgd)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/thinc/api.py", line 300, in finish_update
    d_X = bp_layer(layer.ops.flatten(d_seqs_out, pad=pad), sgd=sgd)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
    gradient = callback(gradient, sgd)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/thinc/neural/_classes/resnet.py", line 37, in residual_bwd
    dX = bp_y(d_output, sgd)
  File "/root/miniconda3/envs/ner/lib/python3.7/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
    gradient = callback(gradient, sgd)
  File "ops.pyx", line 101, in thinc.neural.ops.Ops.dropout.wrap_backprop.finish_update
  File "cupy/core/core.pyx", line 940, in cupy.core.core.ndarray. __mul__
  File "cupy/core/_kernel.pyx", line 811, in cupy.core._kernel.ufunc. __call__
  File "cupy/core/_kernel.pyx", line 89, in cupy.core._kernel._preprocess_args
TypeError: Unsupported type <class 'numpy.ndarray'>

```

Could you please help me to understand the error and using GPU successfully cause I don't understand why I received type error while I didn't get any error of running it locally.  
thanks

---

<div class="post-metadata">

### Author: ![honnibal](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/honnibal/32/35_2.png) [@honnibal](https://support.prodi.gy/u/honnibal)
#### Post date: [August 22, 2019, 5:45pm UTC](https://support.prodi.gy/t/error-using-gpu-with-an-existing-model/1911/2 "2019-08-22T17:45:49Z")

</div>

I think the most likely cause here is that you'll need to run the `spacy.prefer_gpu()` function before you call `spacy.load()`. I suspect you've already loaded your model on CPU before activating the GPU.
