diff --git a/mhcflurry/train_allele_specific_models_command.py b/mhcflurry/train_allele_specific_models_command.py
index b09194aaf4d20810f7b41d0475baa5f1c0b5db26..8646a0208547ed6f241f84496c84b1a568e91ae5 100644
--- a/mhcflurry/train_allele_specific_models_command.py
+++ b/mhcflurry/train_allele_specific_models_command.py
@@ -381,6 +381,9 @@ def calibrate_percentile_ranks(allele, predictor, peptides=None):
     Private helper function.
     """
     global GLOBAL_DATA
+    Class1NeuralNetwork.clear_model_cache()
+    import keras.backend as K
+    K.clear_session()
     if peptides is None:
         peptides = GLOBAL_DATA["calibration_peptides"]
     if isinstance(predictor, str):