Browse Source

修复 bug :兼容 cpu 版本的 PyTorch

TODO:其它地方可能也存在类似的 bug
tags/v0.4.10
ChenXin 5 years ago
parent
commit
3a6a188218
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      fastNLP/core/utils.py

+ 3
- 0
fastNLP/core/utils.py View File

@@ -404,6 +404,9 @@ def _move_dict_value_to_device(*args, device: torch.device, non_blocking=False):
:param args: :param args:
:return: :return:
""" """
if not torch.cuda.is_available():
return
if not isinstance(device, torch.device): if not isinstance(device, torch.device):
raise TypeError(f"device must be `torch.device`, got `{type(device)}`") raise TypeError(f"device must be `torch.device`, got `{type(device)}`")




Loading…
Cancel
Save