Fix evaluate for non-GPU

This commit is contained in:
Matthew Honnibal 2017-10-03 22:47:31 +02:00
parent 32b9f3d1a6
commit f24c2e3a8a
2 changed files with 5 additions and 2 deletions

View File

@ -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. Train a model. Expects data in spaCy's JSON format.
""" """
util.use_gpu(gpu_id) util.use_gpu(gpu_id)
util.set_env_log(True) util.set_env_log(False)
data_path = util.ensure_path(data_path) data_path = util.ensure_path(data_path)
if not data_path.exists(): if not data_path.exists():
prints(data_path, title="Evaluation data not found", exits=1) prints(data_path, title="Evaluation data not found", exits=1)

View File

@ -563,7 +563,10 @@ def minify_html(html):
def use_gpu(gpu_id): def use_gpu(gpu_id):
import cupy.cuda.device try:
import cupy.cuda.device
except ImportError:
return None
from thinc.neural.ops import CupyOps from thinc.neural.ops import CupyOps
device = cupy.cuda.device.Device(gpu_id) device = cupy.cuda.device.Device(gpu_id)
device.use() device.use()