From 2215f46a2ac76e8a0f30c77c676ed141e7ed2bb7 Mon Sep 17 00:00:00 2001 From: wuzewu Date: Tue, 3 Nov 2020 17:47:37 +0800 Subject: [PATCH] Fix the problem that hub.Module load fails in the multi-card environment --- paddlehub/module/module.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/paddlehub/module/module.py b/paddlehub/module/module.py index d2729530..e0a17046 100644 --- a/paddlehub/module/module.py +++ b/paddlehub/module/module.py @@ -202,6 +202,12 @@ class Module(object): else: user_module_cls.source = '' user_module_cls.branch = '' + + # In the case of multiple cards, the following code can set each process to use the correct place. + if issubclass(user_module_cls, paddle.nn.Layer): + place = paddle.get_device().split(':')[0] + paddle.set_device(place) + return user_module_cls @classmethod -- GitLab