Skip to content

Commit f8be17b

Browse files
author
Liu
committed
add a check to determine if horovod.torch import succeeds
1 parent 6b13f09 commit f8be17b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

smdebug/core/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,29 @@ class FRAMEWORK(Enum):
6464
except (ImportError, ModuleNotFoundError):
6565
_torch_dist_imported = None
6666

67-
67+
logger = get_logger()
6868
try:
6969
import horovod.torch as hvd
7070

7171
# This redundant import is necessary because horovod does not raise an ImportError if the library is not present
7272
import torch # noqa
73+
#make sure the library is correctly imported
74+
hvd.init()
7375

7476
_hvd_imported = hvd
77+
except AttributeError:
78+
_hvd_imported = None
79+
logger.error("horovod.torch is not correctly imported.")
80+
raise
7581
except (ModuleNotFoundError, ImportError):
7682
try:
7783
import horovod.tensorflow as hvd
7884

7985
_hvd_imported = hvd
8086
except (ModuleNotFoundError, ImportError):
8187
_hvd_imported = None
88+
raise
8289

83-
84-
logger = get_logger()
8590
error_handling_agent = (
8691
ErrorHandlingAgent.get_error_handling_agent()
8792
) # set up error handler to wrap smdebug functions

0 commit comments

Comments
 (0)