Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpath fix to Native Publish PyTorch #1639

Merged
merged 2 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/native_publish_pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 12 additions & 0 deletions engines/pytorch/pytorch-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def downloadBuildAndroid(String ver) {
}

def prepareNativeLib(String binaryRoot, String ver) {
if (!System.properties['os.name'].toLowerCase(Locale.ROOT).contains("mac")) {
throw new GradleException("This command must be run from osx")
}

def officialPytorchUrl = "https://download.pytorch.org/libtorch"
def aarch64PytorchUrl = "https://djl-ai.s3.amazonaws.com/publish/pytorch"
String cu11
Expand All @@ -102,6 +106,14 @@ def prepareNativeLib(String binaryRoot, String ver) {

copyNativeLibToOutputDir(files, binaryRoot, officialPytorchUrl)
copyNativeLibToOutputDir(aarch64Files, binaryRoot, aarch64PytorchUrl)


exec {
commandLine 'install_name_tool', '-add_rpath', '"@loader_path"', "${binaryRoot}/cpu/osx-x86_64/native/lib/libtorch_cpu.dylib"
}
exec {
commandLine 'install_name_tool', '-add_rpath', '"@loader_path"', "${binaryRoot}/cpu/osx-x86_64/native/lib/libtorch.dylib"
}
}

def copyNativeLibToOutputDir(Map<String, String> fileStoreMap, String binaryRoot, String url) {
Expand Down