Port train CLI updates
Updates from and fix from
* `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
@@ -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:
