Skip to content

Commit

Permalink
[training] SAVE_STATE_WARNING was removed in pytorch (#8979)
Browse files Browse the repository at this point in the history
* [training] SAVE_STATE_WARNING was removed in pytorch

FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: #8232

@sgugger

* style, but add () to prevent autoformatters from botching it

* switch to try/except

* cleanup
  • Loading branch information
stas00 authored Dec 8, 2020
1 parent 2ae7388 commit 9d7d000
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/transformers/trainer_pt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import numpy as np
import torch
from packaging import version
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data.sampler import RandomSampler, Sampler

Expand All @@ -34,10 +33,11 @@
if is_torch_tpu_available():
import torch_xla.core.xla_model as xm

if version.parse(torch.__version__) <= version.parse("1.4.1"):
SAVE_STATE_WARNING = ""
else:
# this is used to supress an undesired warning emitted by pytorch versions 1.4.2-1.7.0
try:
from torch.optim.lr_scheduler import SAVE_STATE_WARNING
except ImportError:
SAVE_STATE_WARNING = ""

logger = logging.get_logger(__name__)

Expand Down

0 comments on commit 9d7d000

Please sign in to comment.