From 3a6a1882181bb0020760123e9f56d15ec123b6c0 Mon Sep 17 00:00:00 2001 From: ChenXin Date: Sun, 5 May 2019 22:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20bug=20=EF=BC=9A=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=20cpu=20=E7=89=88=E6=9C=AC=E7=9A=84=20PyTorch=20TODO?= =?UTF-8?q?=EF=BC=9A=E5=85=B6=E5=AE=83=E5=9C=B0=E6=96=B9=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B9=9F=E5=AD=98=E5=9C=A8=E7=B1=BB=E4=BC=BC=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/core/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastNLP/core/utils.py b/fastNLP/core/utils.py index 23743ecf..33b69d7e 100644 --- a/fastNLP/core/utils.py +++ b/fastNLP/core/utils.py @@ -404,6 +404,9 @@ def _move_dict_value_to_device(*args, device: torch.device, non_blocking=False): :param args: :return: """ + if not torch.cuda.is_available(): + return + if not isinstance(device, torch.device): raise TypeError(f"device must be `torch.device`, got `{type(device)}`")