From 1b20f2d67f02ad6eca3a75c7477e8fdedb05dc58 Mon Sep 17 00:00:00 2001 From: Jinze Xue <155670984+jinzex@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:30:03 -0700 Subject: [PATCH] Fix undefined symbol issue for transformer_engine::getenv (#763) Signed-off-by: Jinze Xue Co-authored-by: Jinze Xue --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index d50a9b8706..d442aec872 100644 --- a/setup.py +++ b/setup.py @@ -445,6 +445,12 @@ def setup_pytorch_extension() -> setuptools.Extension: sources = [ src_dir / "common.cu", src_dir / "ts_fp8_op.cpp", + # We need to compile system.cpp because the pytorch extension uses + # transformer_engine::getenv. This is a workaround to avoid direct + # linking with libtransformer_engine.so, as the pre-built PyTorch + # wheel from conda or PyPI was not built with CXX11_ABI, and will + # cause undefined symbol issues. + root_path / "transformer_engine" / "common" / "util" / "system.cpp", ] + \ _all_files_in_dir(extensions_dir)