[Core] manage nccl via a pypi package & upgrade to pt 2.2.1 (#3805)

This commit is contained in:
youkaichao
2024-04-04 10:26:19 -07:00
committed by GitHub
parent b7782002e1
commit ca81ff5196
8 changed files with 36 additions and 11 deletions

View File

@@ -21,6 +21,7 @@
import ctypes
import datetime
import glob
import os
# ===================== import region =====================
@@ -34,18 +35,27 @@ logger = init_logger(__name__)
so_file = os.environ.get("VLLM_NCCL_SO_PATH", "")
# check if we have vllm-managed nccl
vllm_nccl_path = None
if torch.version.cuda is not None:
cuda_major = torch.version.cuda.split(".")[0]
path = os.path.expanduser(
f"~/.config/vllm/nccl/cu{cuda_major}/libnccl.so.*")
files = glob.glob(path)
vllm_nccl_path = files[0] if files else None
# manually load the nccl library
if so_file:
logger.info(
f"Loading nccl from environment variable VLLM_NCCL_SO_PATH={so_file}")
else:
if torch.version.cuda is not None:
so_file = "libnccl.so.2"
so_file = vllm_nccl_path or "libnccl.so.2"
elif torch.version.hip is not None:
so_file = "librccl.so.1"
else:
raise ValueError("NCCL only supports CUDA and ROCm backends.")
logger.debug(f"Loading nccl from library {so_file}")
logger.info(f"Loading nccl from library {so_file}")
try:
nccl = ctypes.CDLL(so_file)