I have installed spacy cuda using the below, to train a model using the GPU, and speed things up.
pip install -U spacy[cuda92]
To accomplish this, I have modify the train recipe as follows, as shown in the spacy documentation here.
DB = connect()
spacy.require_gpu() # <- Code Added
with _msg.loading(f"Loading '{spacy_model}'..."):
if spacy_model.startswith("blank:"):
nlp = spacy.blank(spacy_model.replace("blank:", ""))
else:
nlp = spacy.load(spacy_model)
_msg.good(f"Loaded model '{spacy_model}'")
However, when I run the train-curve
recipe, I get the below error message complaining that cupy
is missing an attribute. Is this behaviour expected?
$ prodigy train-curve textcat my_textcat en_core_news_lg -n 10 -ns 10
✔ Starting with model 'en_core_news_lg'
Training 10 times with 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% of the
data
=============================== ✨ Train curve ===============================
% Accuracy Difference
---- -------- ----------
Traceback (most recent call last):
File "/home/nmer/.pyenv/versions/3.8.1/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/nmer/.pyenv/versions/3.8.1/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/prodigy/__main__.py", line 60, in <module>
controller = recipe(*args, use_plac=True)
File "cython_src/prodigy/core.pyx", line 300, in prodigy.core.recipe.recipe_decorator.recipe_proxy
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/plac_core.py", line 367, in call
cmd, result = parser.consume(arglist)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/plac_core.py", line 232, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/prodigy/recipes/train.py", line 235, in train_curve
best_scores, baseline = train(
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/prodigy/recipes/train.py", line 164, in train
nlp.update(docs, annots, drop=dropout, losses=losses)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/spacy/language.py", line 529, in update
proc.update(docs, golds, sgd=get_grads, losses=losses, **kwargs)
File "pipes.pyx", line 1016, in spacy.pipeline.pipes.TextCategorizer.update
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
gradient = callback(gradient, sgd)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/api.py", line 174, in finish_update
d = bwd(
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
gradient = callback(gradient, sgd)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/spacy/_ml.py", line 823, in concatenate_lists_bwd
return bp_flat_y(ops.flatten(d_ys), sgd=sgd)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/api.py", line 174, in finish_update
d = bwd(
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/neural/_classes/feed_forward.py", line 53, in continue_update
gradient = callback(gradient, sgd)
File "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/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 "/home/nmer/.pyenv/versions/Prodigy2/lib/python3.8/site-packages/thinc/api.py", line 384, in uniqued_bwd
layer.ops.scatter_add(dY_uniq, layer.ops.asarray(inv, dtype="i"), dY)
File "ops.pyx", line 1087, in thinc.neural.ops.CupyOps.scatter_add
AttributeError: module 'cupy' has no attribute 'scatter_add'