mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Make pretraining script work without GPU
This commit is contained in:
parent
bc8cda818c
commit
09aa616182
|
@ -21,7 +21,6 @@ from spacy.util import minibatch, use_gpu, compounding
|
||||||
import tqdm
|
import tqdm
|
||||||
from spacy._ml import Tok2Vec
|
from spacy._ml import Tok2Vec
|
||||||
from spacy.pipeline import TextCategorizer
|
from spacy.pipeline import TextCategorizer
|
||||||
import cupy.random
|
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +56,8 @@ def prefer_gpu():
|
||||||
if used is None:
|
if used is None:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
import cupy.random
|
||||||
|
cupy.random.seed(0)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,7 +178,6 @@ def evaluate_textcat(tokenizer, textcat, texts, cats):
|
||||||
def main(width: int, embed_size: int, vectors_model,
|
def main(width: int, embed_size: int, vectors_model,
|
||||||
pretrain_iters=30, train_iters=30, train_examples=1000):
|
pretrain_iters=30, train_iters=30, train_examples=1000):
|
||||||
random.seed(0)
|
random.seed(0)
|
||||||
cupy.random.seed(0)
|
|
||||||
numpy.random.seed(0)
|
numpy.random.seed(0)
|
||||||
use_gpu = prefer_gpu()
|
use_gpu = prefer_gpu()
|
||||||
print("Using GPU?", use_gpu)
|
print("Using GPU?", use_gpu)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user