mirror of
https://github.com/explosion/spaCy.git
synced 2025-05-29 10:13:19 +03:00
Port train CLI updates
Updates from #5362 and fix from #5387: * `train`: * if training on GPU, only run evaluation/timing on CPU in the first iteration * if training is aborted, exit with a non-0 exit status
This commit is contained in:
parent
581bda9f98
commit
f1f9c8b417
|
@ -458,6 +458,9 @@ def train(
|
|||
cpu_wps = nwords / (end_time - start_time)
|
||||
else:
|
||||
gpu_wps = nwords / (end_time - start_time)
|
||||
# Evaluate on CPU in the first iteration only (for
|
||||
# timing) when GPU is enabled
|
||||
if i == 0:
|
||||
with use_ops("numpy"):
|
||||
nlp_loaded = util.load_model_from_path(epoch_model_path)
|
||||
for name, component in nlp_loaded.pipeline:
|
||||
|
@ -550,7 +553,7 @@ def train(
|
|||
)
|
||||
break
|
||||
except Exception as e:
|
||||
msg.warn(f"Aborting and saving final best model. Encountered exception: {e}")
|
||||
msg.warn(f"Aborting and saving final best model. Encountered exception: {e}", exits=1)
|
||||
finally:
|
||||
best_pipes = nlp.pipe_names
|
||||
if disabled_pipes:
|
||||
|
|
Loading…
Reference in New Issue
Block a user