From 63ff233ba22c947e65d4a52e4f847e751d32ff16 Mon Sep 17 00:00:00 2001 From: Matthw Honnibal Date: Sun, 6 Oct 2019 19:24:21 +0200 Subject: [PATCH] Enable GPU in pytorch n use_gpu functon --- spacy/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spacy/util.py b/spacy/util.py index c7ce38c3f..032c1741a 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -707,6 +707,11 @@ def use_gpu(gpu_id): device.use() Model.ops = CupyOps() Model.Ops = CupyOps + try: + import torch + torch.set_default_tensor_type("torch.cuda.FloatTensor") + except ImportError: + pass return device