From 118ecfd4273b5381aeeb65476a01678c7a96ae3e Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 6 Aug 2020 21:14:46 +0200 Subject: [PATCH] fix for pytorch < 1.6 (#6300) --- src/transformers/modeling_reformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/modeling_reformer.py b/src/transformers/modeling_reformer.py index 6049dc3ed..b214c6d5e 100644 --- a/src/transformers/modeling_reformer.py +++ b/src/transformers/modeling_reformer.py @@ -1400,7 +1400,7 @@ class ReformerLayer(nn.Module): # randomize seeds # use cuda generator if available - if len(torch.cuda.default_generators) > 0: + if hasattr(torch.cuda, "default_generators") and len(torch.cuda.default_generators) > 0: # GPU device_idx = torch.cuda.current_device() self.attention_seed = torch.cuda.default_generators[device_idx].seed() @@ -1420,7 +1420,7 @@ class ReformerLayer(nn.Module): """ # randomize seeds # use cuda generator if available - if len(torch.cuda.default_generators) > 0: + if hasattr(torch.cuda, "default_generators") and len(torch.cuda.default_generators) > 0: # GPU device_idx = torch.cuda.current_device() self.feed_forward_seed = torch.cuda.default_generators[device_idx].seed()