From f24c2e3a8af785dd11b8d0a994732174290d688b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 3 Oct 2017 22:47:31 +0200 Subject: [PATCH] Fix evaluate for non-GPU --- spacy/cli/evaluate.py | 2 +- spacy/util.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spacy/cli/evaluate.py b/spacy/cli/evaluate.py index f409821b1..d9be95fae 100644 --- a/spacy/cli/evaluate.py +++ b/spacy/cli/evaluate.py @@ -39,7 +39,7 @@ def evaluate(cmd, model, data_path, gpu_id=-1, gold_preproc=False): Train a model. Expects data in spaCy's JSON format. """ util.use_gpu(gpu_id) - util.set_env_log(True) + util.set_env_log(False) data_path = util.ensure_path(data_path) if not data_path.exists(): prints(data_path, title="Evaluation data not found", exits=1) diff --git a/spacy/util.py b/spacy/util.py index 911970831..e1a721a12 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -563,7 +563,10 @@ def minify_html(html): def use_gpu(gpu_id): - import cupy.cuda.device + try: + import cupy.cuda.device + except ImportError: + return None from thinc.neural.ops import CupyOps device = cupy.cuda.device.Device(gpu_id) device.use()