Skip to content

Commit 8f80818

Browse files
committed
[multimodal] Fix pybind in nightly wheel build
Right now after ``` pip install executorch==1.1.0.dev20251001 --extra-index-url https://download.pytorch.org/whl/nightly ``` Then run ``` python -c "from executorch.extension.llm.runner import MultimodalRunner" ``` I'm getting this error: ``` (executorch) [[email protected] /data/users/larryliu/executorch (main)]$ python -c "from executorch.extension.llm.runner import MultimodalRunner" Traceback (most recent call last): File "/home/larryliu/.conda/envs/executorch/lib/python3.11/site-packages/executorch/extension/llm/runner/__init__.py", line 16, in <module> from executorch.extension.llm.runner._llm_runner import ( # noqa: F401 ImportError: libtorch_python.so: cannot open shared object file: No such file or directory During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/larryliu/.conda/envs/executorch/lib/python3.11/site-packages/executorch/extension/llm/runner/__init__.py", line 29, in <module> raise RuntimeError( RuntimeError: LLM runner is not installed. Please build ExecuTorch from source with EXECUTORCH_BUILD_PYBIND=ON ``` This PR should fix it by properly point to the installation path of pytorch.
1 parent 07dcd95 commit 8f80818

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

extension/llm/runner/CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,26 @@ if(EXECUTORCH_BUILD_PYBIND)
106106
)
107107
if(APPLE)
108108
set(RPATH "@loader_path/../../pybindings")
109+
set(TORCH_RPATH "@loader_path/../../../torch/lib")
109110
else()
110111
set(RPATH "$ORIGIN/../../pybindings")
112+
set(TORCH_RPATH "$ORIGIN/../../../torch/lib")
111113
endif()
112-
set_target_properties(_llm_runner PROPERTIES INSTALL_RPATH ${RPATH})
114+
# Set RPATH to find PyTorch libraries relative to the installation location
115+
# This goes from executorch/extension/pybindings up to site-packages, then to
116+
# torch/lib. This is copied from root level CMakeLists.txt
117+
if(APPLE)
118+
set_target_properties(
119+
_llm_runner PROPERTIES BUILD_RPATH "${TORCH_RPATH}"
120+
INSTALL_RPATH "${RPATH};${TORCH_RPATH}"
121+
)
122+
else()
123+
set_target_properties(
124+
_llm_runner PROPERTIES BUILD_RPATH "${TORCH_RPATH}"
125+
INSTALL_RPATH "${RPATH};${TORCH_RPATH}"
126+
)
127+
endif()
128+
113129
# Add include directories
114130
target_include_directories(
115131
_llm_runner PRIVATE ${_common_include_directories} ${TORCH_INCLUDE_DIRS}

0 commit comments

Comments
 (0)