File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ print_cmake_info() {
9999 # Explicitly add conda env lib folder to cmake rpath to address the flaky issue
100100 # where cmake dependencies couldn't be found. This seems to point to how conda
101101 # links $CMAKE_EXEC to its package cache when cloning a new environment
102- # install_name_tool -add_rpath @executable_path/../lib "${CMAKE_EXEC}" || true
102+ install_name_tool -add_rpath @executable_path/../lib " ${CMAKE_EXEC} " || true
103103 # Adding the rpath will invalidate cmake signature, so signing it again here
104104 # to trust the executable. EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
105105 # with an exit code 137 otherwise
Original file line number Diff line number Diff line change @@ -44,6 +44,51 @@ install_pip_dependencies() {
4444 popd || return
4545}
4646
47+ dedupe_macos_loader_path_rpaths () {
48+ if [[ " $( uname) " != " Darwin" ]]; then
49+ return
50+ fi
51+
52+ local torch_lib_dir
53+ torch_lib_dir=$( python - << 'PY '
54+ import os
55+ try:
56+ import torch
57+ except Exception:
58+ raise SystemExit(0)
59+
60+ print(os.path.join(os.path.dirname(torch.__file__), "lib"))
61+ PY
62+ )
63+
64+ if [[ -z " ${torch_lib_dir} " || ! -d " ${torch_lib_dir} " ]]; then
65+ return
66+ fi
67+
68+ local torch_libs=(
69+ " libtorch_cpu.dylib"
70+ " libtorch.dylib"
71+ " libc10.dylib"
72+ )
73+
74+ for lib_name in " ${torch_libs[@]} " ; do
75+ local lib_path=" ${torch_lib_dir} /${lib_name} "
76+ if [[ ! -f " ${lib_path} " ]]; then
77+ continue
78+ fi
79+
80+ local removed=0
81+ # Repeatedly remove the @loader_path rpath entries until none remain.
82+ while install_name_tool -delete_rpath @loader_path " ${lib_path} " 2> /dev/null; do
83+ removed=1
84+ done
85+
86+ if [[ " ${removed} " == " 1" ]]; then
87+ install_name_tool -add_rpath @loader_path " ${lib_path} " || true
88+ fi
89+ done
90+ }
91+
4792install_domains () {
4893 echo " Install torchvision and torchaudio"
4994 pip install --no-use-pep517 --user " git+https://github.com/pytorch/audio.git@${TORCHAUDIO_VERSION} "
@@ -101,6 +146,7 @@ install_pytorch_and_domains() {
101146 echo " Use cached wheel at ${cached_torch_wheel} "
102147 fi
103148
149+ dedupe_macos_loader_path_rpaths
104150 # Grab the pinned audio and vision commits from PyTorch
105151 TORCHAUDIO_VERSION=$( cat .github/ci_commit_pins/audio.txt)
106152 export TORCHAUDIO_VERSION
You can’t perform that action at this time.
0 commit comments