Skip to content

Commit

Permalink
ci: bump torch version
Browse files Browse the repository at this point in the history
  • Loading branch information
elgiano committed May 22, 2024
1 parent c92a5ea commit a2c9dc7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 36 deletions.
34 changes: 29 additions & 5 deletions .github/workflows/pluginbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: false
default: 'manual_run'
jobs:
build:

Expand All @@ -14,11 +19,11 @@ jobs:

- name: 'Linux-x64'
os: ubuntu-latest
torch: https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip
torch: https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.0%2Bcpu.zip

- name: 'Windows-x64'
os: windows-latest
torch: https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.0.1%2Bcpu.zip
torch: https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.3.0%2Bcpu.zip

- name: 'macOS-x64'
os: macos-12
Expand All @@ -27,7 +32,7 @@ jobs:
- name: 'macOS-arm64'
arch: arm64
os: macos-12
torch: https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.3.0.zip
torch: https://files.pythonhosted.org/packages/55/51/4bdee83e6fa9cca8e3a6cdf81a2695ede9d3fd7148e4fd4188dff142d7b0/torch-2.3.0-cp312-none-macosx_11_0_arm64.whl

env:
SC_PATH: ${{ github.workspace }}/supercollider
Expand All @@ -50,11 +55,18 @@ jobs:

# Get libtorch
- name: Download libtorch (Unix)
if: runner.os != 'Windows'
if: runner.os != 'Windows' && matrix.arch != 'arm64'
run: |
wget ${{ matrix.torch }} -O libtorch.zip
unzip libtorch.zip
- name: Download libtorch (MacOS arm64)
if: matrix.arch == 'arm64'
run: |
wget ${{ matrix.torch }} -O libtorch.whl
unzip libtorch.whl "torch/*"
mv torch libtorch
- name: Download libtorch (Windows)
if: runner.os == 'Windows'
run: |
Expand Down Expand Up @@ -94,10 +106,22 @@ jobs:

# Upload
- name: Upload binaries to release
if: github.event_name == 'push'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.INSTALL_PATH }}/${{ env.ARCHIVE_NAME }}
prerelease: true
body: ""
tag: ${{ github.ref }}

# Upload: manual trigger
- name: Upload binaries to release
if: github.event_name == 'workflow_dispatch'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.INSTALL_PATH }}/${{ env.ARCHIVE_NAME }}
prerelease: true
body: ""
tag: ${{github.event.inputs.tag_name}}
66 changes: 35 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ option(SCSYNTH "Build plugins for scsynth" ON)
option(NATIVE "Optimize for native architecture" OFF)
option(STRICT "Use strict warning flags" OFF)
option(NOVA_SIMD "Build plugins with nova-simd support." ON)
option(SYSTEM_TORCH "Use system-installed torch (and don't copy shared libraries)" OFF)
set(TORCH_PATH "" CACHE STRING "Path to libtorch")

####################################################################################################
Expand All @@ -65,42 +66,45 @@ if (NOVA_SIMD)
include_directories(${SC_PATH}/external_libraries/nova-simd)
endif()

if (${SYSTEM_TORCH})
find_package(Torch REQUIRED)
else()
# find torch
message(STATUS "Torch install path: ${TORCH_PATH}")
if ("${TORCH_PATH}" STREQUAL "")
message(FATAL_ERROR "TORCH_PATH required but not provided")
endif()
if (NOT EXISTS ${TORCH_PATH})
message(FATAL_ERROR "TORCH_PATH '${TORCH_PATH}' does not exist")
endif()
message(STATUS "Torch install path: ${TORCH_PATH}")
if ("${TORCH_PATH}" STREQUAL "")
message(FATAL_ERROR "TORCH_PATH required but not provided")
endif()
if (NOT EXISTS ${TORCH_PATH})
message(FATAL_ERROR "TORCH_PATH '${TORCH_PATH}' does not exist")
endif()

find_package(Torch REQUIRED PATHS "${TORCH_PATH}" NO_DEFAULT_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
find_package(Torch REQUIRED PATHS "${TORCH_PATH}" NO_DEFAULT_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

# copy shared libs
set(TORCH_SO ${TORCH_LIBRARY} ${c10_LIBRARY})
if (LINUX)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/libtorch_cpu.*"
"${TORCH_INSTALL_PREFIX}/lib/libgomp*"
)
list(APPEND TORCH_SO ${GLOB_TORCH_SO})
set(CMAKE_INSTALL_RPATH "$ORIGIN/ignore")
elseif (APPLE)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/libtorch_cpu.*"
)
# file(GLOB TORCH_SO "${TORCH_INSTALL_PREFIX}/lib/*.dylib")
list(APPEND TORCH_SO ${GLOB_TORCH_SO})
set(CMAKE_INSTALL_RPATH "@loader_path/ignore")
elseif (MSVC)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/torch_cpu.dll"
# "${TORCH_INSTALL_PREFIX}/lib/libiomp5md.dll"
)
# file(GLOB TORCH_SO "${TORCH_INSTALL_PREFIX}/lib/*.dll")
set(TORCH_SO ${TORCH_LIBRARY} ${c10_LIBRARY})
if (LINUX)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/libtorch_cpu.*"
"${TORCH_INSTALL_PREFIX}/lib/libgomp*"
)
list(APPEND TORCH_SO ${GLOB_TORCH_SO})
set(CMAKE_INSTALL_RPATH "$ORIGIN/ignore")
elseif (APPLE)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/libtorch_cpu.*"
"${TORCH_INSTALL_PREFIX}/lib/libomp*"
)
list(APPEND TORCH_SO ${GLOB_TORCH_SO})
set(CMAKE_INSTALL_RPATH "@loader_path/ignore")
elseif (MSVC)
file(GLOB GLOB_TORCH_SO
"${TORCH_INSTALL_PREFIX}/lib/torch_cpu.dll"
"${TORCH_INSTALL_PREFIX}/lib/libiomp5md.dll"
)
endif()
install(FILES ${TORCH_SO} DESTINATION "${dest_dir}/ignore")
endif()
install(FILES ${TORCH_SO} DESTINATION "${dest_dir}/ignore")

message(STATUS "Torch libs: ${TORCH_LIBRARIES}")
message(STATUS "Torch shared libraries to be copied:")
Expand Down

0 comments on commit a2c9dc7

Please sign in to comment.