5 from .env
import IS_CONDA, IS_LINUX, IS_WINDOWS, CONDA_DIR, check_env_flag, check_negative_env_flag, gather_paths
6 from .cuda
import USE_CUDA
9 USE_DISTRIBUTED =
not check_negative_env_flag(
"USE_DISTRIBUTED")
and not IS_WINDOWS
and not check_env_flag(
"USE_ROCM")
10 USE_GLOO_IBVERBS =
False 12 IB_DEVINFO_CMD =
"ibv_devinfo" 15 def get_command_path(command):
17 Helper function that checks if the command exists in the path and gets the 18 full path of a given linux command if it exists. 20 def excutable(command_path):
21 return os.path.isfile(command_path)
and os.access(command_path, os.X_OK)
23 for path
in os.environ[
"PATH"].
split(os.pathsep):
24 command_path = os.path.join(path, command)
25 if excutable(command_path):
31 def should_build_ib():
33 Helper function that detects the system's IB support and returns if we 34 should build with IB support. 38 ib_header_found =
False 43 full_cmd_path = get_command_path(IB_DEVINFO_CMD)
46 subprocess.check_output([full_cmd_path,
"--list"])
69 lib_paths = list(filter(bool, [
71 "/usr/lib/x86_64-linux-gnu/",
72 "/usr/lib/powerpc64le-linux-gnu/",
73 "/usr/lib/aarch64-linux-gnu/",
85 lib_paths.append(os.path.join(CONDA_DIR,
"lib"))
86 include_paths.append(os.path.join(CONDA_DIR,
"include"))
88 for path
in lib_paths:
89 if path
is None or not os.path.exists(path):
91 ib_libraries = sorted(glob.glob(os.path.join(path,
"libibverbs*")))
96 for path
in include_paths:
97 if path
is None or not os.path.exists(path):
99 if os.path.exists(os.path.join(path,
"infiniband/verbs.h")):
100 ib_header_found =
True 103 return ib_util_found
and ib_lib_found
and ib_lib_found
108 if "USE_GLOO_IBVERBS" in os.environ:
109 USE_GLOO_IBVERBS = check_env_flag(
"USE_GLOO_IBVERBS")
111 USE_GLOO_IBVERBS = should_build_ib()
Module caffe2.python.layers.split.