diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index 425cc39338e7b3..525708645c2c49 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -1498,6 +1498,8 @@ def optimizer_hook(param): "You need to install `schedulefree` in order to use schedulefree optimizers" " install it with `pip install schedulefree`" ) + if not is_accelerate_available("0.30.0"): + raise ImportError("You need to have `accelerate>=0.30.0` to be able to use schedulefree optimizers") from schedulefree import AdamWScheduleFree, SGDScheduleFree additional_optim_kwargs = {}