Skip to content

Commit

Permalink
Update PyTorch to 1.12.0 (#21)
Browse files Browse the repository at this point in the history
* Update PyTorch to 1.12.0

* restore windows version to latest

* fix cuda version

* fix cuda install script

* fix ubuntu build script

* update packages

* try fix cudnn install on windows

* try fix cudnn install on windows 2

* try fix cudnn install on windows 3

* try fix cudnn install on windows 4

* try fix cudnn install on windows 5

* try fix cudnn install on windows 6
  • Loading branch information
arition authored Jul 25, 2022
1 parent 2b3bbdc commit c94aa01
Show file tree
Hide file tree
Showing 10 changed files with 685 additions and 630 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-2019]
os: [macos-latest, ubuntu-latest, windows-latest]
if: "!contains(github.event.head_commit.message, 'ci skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
Expand Down
42 changes: 24 additions & 18 deletions .github/workflows/publish-prebuild-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2019]
os: [ubuntu-latest, windows-latest]
if: "!contains(github.event.head_commit.message, 'publish-prebuild skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install CUDA on windows-2019
if: ${{ matrix.os == 'windows-2019' }}
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '16'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Setup Conda to install cudnn on windows-latest
uses: s-weigand/setup-conda@v1
if: ${{ matrix.os == 'windows-latest' }}
with:
activate-conda: false

- name: Install CUDA on windows-latest
if: ${{ matrix.os == 'windows-latest' }}
shell: powershell
env:
cuda: "11.3.0"
cudnn: "8.2.1.32"
cuda: "11.6.2"
cudnn: "8.4.0.27"
run: |
# Install CUDA via a powershell script
.\.github\workflows\scripts\install_cuda_windows.ps1
Expand All @@ -43,8 +59,8 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
env:
cuda: "11.3.0"
cudnn: "8.2.1.32"
cuda: "11.6.2"
cudnn: "8.4.0.27"
run: |
source ./.github/workflows/scripts/install_cuda_ubuntu.sh
if [[ $? -eq 0 ]]; then
Expand All @@ -55,24 +71,14 @@ jobs:
echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
fi
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '16'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install packages
run: yarn upgrade --dev

- name: Prebuild
run: yarn build-prebuild

- name: Check prebuild bundle size
if: ${{ matrix.os == 'windows-2019' }}
if: ${{ matrix.os == 'windows-latest' }}
shell: powershell
run: |
ls prebuilds/@arition
Expand Down
42 changes: 24 additions & 18 deletions .github/workflows/publish-prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-2019]
os: [macos-latest, ubuntu-latest, windows-latest]
if: "!contains(github.event.head_commit.message, 'publish-prebuild skip')"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install CUDA on windows-2019
if: ${{ matrix.os == 'windows-2019' }}
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '16'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Setup Conda to install cudnn on windows-latest
uses: s-weigand/setup-conda@v1
if: ${{ matrix.os == 'windows-latest' }}
with:
activate-conda: false

- name: Install CUDA on windows-latest
if: ${{ matrix.os == 'windows-latest' }}
shell: powershell
env:
cuda: "11.3.0"
cudnn: "8.2.1.32"
cuda: "11.6.2"
cudnn: "8.4.0.27"
run: |
# Install CUDA via a powershell script
.\.github\workflows\scripts\install_cuda_windows.ps1
Expand All @@ -43,8 +59,8 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
env:
cuda: "11.3.0"
cudnn: "8.2.1.32"
cuda: "11.6.2"
cudnn: "8.4.0.27"
run: |
source ./.github/workflows/scripts/install_cuda_ubuntu.sh
if [[ $? -eq 0 ]]; then
Expand All @@ -55,24 +71,14 @@ jobs:
echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
fi
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '16'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install packages
run: yarn upgrade --dev

- name: Prebuild
run: yarn build-prebuild

- name: Check prebuild bundle size
if: ${{ matrix.os == 'windows-2019' }}
if: ${{ matrix.os == 'windows-latest' }}
shell: powershell
run: |
ls prebuilds/@arition
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/scripts/install_cuda_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ echo "CUDA_PACKAGES ${CUDA_PACKAGES}"
PIN_FILENAME="cuda-ubuntu${UBUNTU_VERSION}.pin"
PIN_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/${PIN_FILENAME}"
APT_KEY_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/7fa2af80.pub"
APT_KEY_URL2="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/3bf863cc.pub"
REPO_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64"
CUDNN_REPO_URL="https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu${UBUNTU_VERSION}/x86_64"

echo "PIN_FILENAME ${PIN_FILENAME}"
echo "PIN_URL ${PIN_URL}"
echo "APT_KEY_URL ${APT_KEY_URL}"
echo "APT_KEY_URL2 ${APT_KEY_URL2}"

## -----------------
## Install
Expand All @@ -125,6 +127,7 @@ echo "Adding CUDA Repository"
# wget ${PIN_URL}
# sudo mv ${PIN_FILENAME} /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys ${APT_KEY_URL}
sudo apt-key adv --fetch-keys ${APT_KEY_URL2}
sudo add-apt-repository "deb ${REPO_URL} /"
sudo add-apt-repository "deb ${CUDNN_REPO_URL} /"
sudo apt-get update
Expand Down
23 changes: 4 additions & 19 deletions .github/workflows/scripts/install_cuda_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $CUDA_KNOWN_URLS = @{
"11.0.2" = "https://developer.download.nvidia.com/compute/cuda/11.0.2/network_installers/cuda_11.0.2_win10_network.exe";
"11.1.1" = "https://developer.download.nvidia.com/compute/cuda/11.1.1/network_installers/cuda_11.1.1_win10_network.exe";
"11.3.1" = "https://developer.download.nvidia.com/compute/cuda/11.3.1/network_installers/cuda_11.3.1_win10_network.exe";
"11.6.2" = "https://developer.download.nvidia.com/compute/cuda/11.6.2/network_installers/cuda_11.6.2_windows_network.exe";
}

# cuda_runtime.h is in nvcc <= 10.2, but cudart >= 11.0
Expand Down Expand Up @@ -93,10 +94,10 @@ if($CUDA_KNOWN_URLS.containsKey($CUDA_VERSION_FULL)){
} else{
# Guess what the url is given the most recent pattern (at the time of writing, 11)
Write-Output "note: URL for CUDA ${$CUDA_VERSION_FULL} not known, estimating."
$CUDA_REPO_PKG_REMOTE="http://developer.download.nvidia.com/compute/cuda/$($CUDA_VERSION_FULL)/network_installers/cuda_$($CUDA_VERSION_FULL)_win10_network.exe"
$CUDA_REPO_PKG_REMOTE="https://developer.download.nvidia.com/compute/cuda/$($CUDA_VERSION_FULL)/network_installers/cuda_$($CUDA_VERSION_FULL)_windows_network.exe"
}
$TEMP_PATH = [System.IO.Path]::GetTempPath()
$CUDA_REPO_PKG_LOCAL = Join-Path $TEMP_PATH "cuda_$($CUDA_VERSION_FULL)_win10_network.exe"
$CUDA_REPO_PKG_LOCAL = Join-Path $TEMP_PATH "cuda_$($CUDA_VERSION_FULL)_windows_network.exe"


## ------------
Expand Down Expand Up @@ -131,23 +132,7 @@ $CUDA_PATH_VX_Y = "CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)"
# Append $CUDA_PATH/bin to path.
# Set CUDA_PATH as an environmental variable

$CUDNN_ZIP_REMOTE = "http://developer.download.nvidia.com/compute/redist/cudnn/v$($CUDNN_MAJOR).$($CUDNN_MINOR).$($CUDNN_PATCH)/cudnn-$($CUDA_MAJOR).$($CUDA_MINOR)-windows-x64-v$($CUDNN_VERSION_FULL).zip"
$CUDNN_ZIP_LOCAL = Join-Path $TEMP_PATH "cudnn.zip"

Write-Output "Downloading CUDNN zip for $($CUDNN_VERSION_FULL) from: $($CUDNN_ZIP_REMOTE)"
Invoke-WebRequest $CUDNN_ZIP_REMOTE -OutFile $CUDNN_ZIP_LOCAL | Out-Null
if(Test-Path -Path $CUDNN_ZIP_LOCAL){
Write-Output "Downloading Complete"
} else {
Write-Output "Error: Failed to download $($CUDNN_ZIP_LOCAL) from $($CUDNN_ZIP_REMOTE)"
exit 1
}

Write-Output "Installing CUDNN"

Expand-Archive -Path $CUDNN_ZIP_LOCAL -DestinationPath $TEMP_PATH
$CUDNN_EXPAND_LOCAL = Join-Path $TEMP_PATH "cuda"
Copy-Item -Path "$($CUDNN_EXPAND_LOCAL)/*" -Destination $CUDA_PATH -Filter *.* -Force -recurse
conda install -y -c conda-forge cudnn=$($CUDNN_VERSION_FULL)

# Set environmental variables in this session
$env:CUDA_PATH = "$($CUDA_PATH)"
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project (torch-js)

set(PYTORCH_VERSION 1.11.0)
set(PYTORCH_VISION_VERSION 0.12.0)
set(PYTORCH_VERSION 1.12.0)
set(PYTORCH_VISION_VERSION 0.13.0)
find_package(CUDA)
if(CUDA_FOUND)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/build/libtorch")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arition/torch-js",
"version": "0.13.1",
"version": "0.14.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Kittipat Virochsiri, arition, raghavmecheri",
Expand Down
20 changes: 11 additions & 9 deletions patches/0001-Remove-native-image-support.patch
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
From 0f0fe21cbf5e12214e1e7d9807cac8478714f300 Mon Sep 17 00:00:00 2001
From cb1e7910b785fdb14a6deb52631c9415c49b5089 Mon Sep 17 00:00:00 2001
From: arition <[email protected]>
Date: Tue, 1 Dec 2020 00:17:44 -0800
Subject: [PATCH] Remove native image support

---
CMakeLists.txt | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
CMakeLists.txt | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87179c147..404f5d4a7 100644
index 4e222dbfa..404f5d4a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,8 +24,6 @@ if (USE_PYTHON)
@@ -24,10 +24,6 @@ if (USE_PYTHON)
endif()

find_package(Torch REQUIRED)
-find_package(PNG REQUIRED)
-find_package(JPEG REQUIRED)
-add_definitions(-DJPEG_FOUND)
-add_definitions(-DPNG_FOUND)

function(CUDA_CONVERT_FLAGS EXISTING_TARGET)
get_property(old_flags TARGET ${EXISTING_TARGET} PROPERTY INTERFACE_COMPILE_OPTIONS)
@@ -37,6 +35,14 @@ function(CUDA_CONVERT_FLAGS EXISTING_TARGET)
@@ -39,6 +35,14 @@ function(CUDA_CONVERT_FLAGS EXISTING_TARGET)
endif()
endfunction()

Expand All @@ -35,7 +37,7 @@ index 87179c147..404f5d4a7 100644
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
if(WITH_CUDA)
@@ -80,7 +86,7 @@ FOREACH(DIR ${ALLOW_LISTED})
@@ -82,7 +86,7 @@ FOREACH(DIR ${ALLOW_LISTED})
ENDFOREACH()

add_library(${PROJECT_NAME} SHARED ${ALL_SOURCES})
Expand All @@ -44,7 +46,7 @@ index 87179c147..404f5d4a7 100644

if (USE_PYTHON)
target_link_libraries(${PROJECT_NAME} PRIVATE Python3::Python)
@@ -90,7 +96,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
@@ -92,7 +96,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
EXPORT_NAME TorchVision
INSTALL_RPATH ${TORCH_INSTALL_PREFIX}/lib)

Expand All @@ -54,5 +56,5 @@ index 87179c147..404f5d4a7 100644
set(TORCHVISION_CMAKECONFIG_INSTALL_DIR "share/cmake/TorchVision" CACHE STRING "install path for TorchVisionConfig.cmake")

--
2.34.1.windows.1
2.37.1.windows.1

2 changes: 1 addition & 1 deletion tests/scriptmodule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Constructor', () => {
// TODO -- Fine tune error message to remove stacktrace for error thrown on invalid model file
test('Call constructor from invalid model path', () => {
const t = () => new torch.ScriptModule('/resources/no_model.pt');
expect(t).toThrow(/open file failed because of errno 2 on fopen.*/);
expect(t).toThrow(/Unrecognized data format*/);
expect(true).toEqual(true);
});

Expand Down
Loading

0 comments on commit c94aa01

Please sign in to comment.