Skip to content

Commit 850d76d

Browse files
larryliu0820claude
andauthored
Fix libaoti_cuda_shims.so not found when importing _portable_lib on Linux (#17632)
When ExecuTorch is built with CUDA support and installed as a pip package, importing `_portable_lib` fails with: ImportError: libaoti_cuda_shims.so: cannot open shared object file This happens because: 1. `_portable_lib.so` links against `libaoti_cuda_shims.so` (via `aoti_cuda_backend`), but the RPATH only contains a stale build-time temp directory path that no longer exists after installation. 2. `setup.py` only installs the Windows `.lib` import library, not the Linux `.so` shared library. Fix both issues: - Add `$ORIGIN/../../backends/cuda` to the `_portable_lib` RPATH when CUDA is enabled, following the same pattern used for QNN. - Add a `BuiltFile` entry in `setup.py` to install `libaoti_cuda_shims.so` into `executorch/backends/cuda/` in the pip package. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 67f1d19 commit 850d76d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,10 @@ if(EXECUTORCH_BUILD_PYBIND)
947947
list(APPEND _dep_libs openvino_backend)
948948
endif()
949949

950+
if(EXECUTORCH_BUILD_CUDA)
951+
string(APPEND _portable_lib_rpath ":$ORIGIN/../../backends/cuda")
952+
endif()
953+
950954
if(EXECUTORCH_BUILD_QNN)
951955
list(APPEND _dep_libs qnn_executorch_backend)
952956
string(APPEND _portable_lib_rpath ":$ORIGIN/../../backends/qualcomm")

setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,13 @@ def run(self): # noqa C901
869869
dst="executorch/data/lib/",
870870
dependent_cmake_flags=[],
871871
),
872+
BuiltFile(
873+
src_dir="%CMAKE_CACHE_DIR%/backends/cuda/%BUILD_TYPE%/",
874+
src_name="aoti_cuda_shims",
875+
dst="executorch/backends/cuda/",
876+
is_dynamic_lib=True,
877+
dependent_cmake_flags=["EXECUTORCH_BUILD_CUDA"],
878+
),
872879
BuiltFile(
873880
src_dir="%CMAKE_CACHE_DIR%/backends/qualcomm/%BUILD_TYPE%/",
874881
src_name="qnn_executorch_backend",

0 commit comments

Comments
 (0)