Skip to content

Commit

Permalink
support torch 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 22, 2023
1 parent d37b2bb commit 50e2af6
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
python-version: [3.8]
steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -38,7 +38,7 @@ jobs:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-tests-macos-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -45,14 +45,14 @@ jobs:
run_tests_macos_cpu:
needs: generate_build_matrix
runs-on: macos-10.15
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/run-tests-ubuntu-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -52,7 +52,7 @@ jobs:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -61,12 +61,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install GCC 7
run: |
sudo apt-get install -y gcc-7 g++-7
echo "CC=/usr/bin/gcc-7" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-7" >> $GITHUB_ENV
- name: Install PyTorch ${{ matrix.torch }}
shell: bash
run: |
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/run-tests-ubuntu-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -45,14 +45,14 @@ jobs:
run_tests_ubuntu_cuda:
needs: generate_build_matrix
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -61,14 +61,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install GCC 7
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install -y gcc-7 g++-7
echo "CC=/usr/bin/gcc-7" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-7" >> $GITHUB_ENV
- name: Install CUDA Toolkit ${{ matrix.cuda }}
shell: bash
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-tests-windows-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -46,14 +46,14 @@ jobs:
run_tests_windows_cpu:
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
needs: generate_build_matrix
runs-on: windows-2019
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-tests-windows-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -46,14 +46,14 @@ jobs:
run_tests_windows_cuda:
needs: generate_build_matrix
runs-on: windows-2019
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/style_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-10.15]
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest]
python-version: ["3.8"]
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: ["3.8", "3.9", "3.10"]
steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -38,7 +38,7 @@ jobs:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-x64-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generating build matrix
Expand All @@ -38,7 +38,7 @@ jobs:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
9 changes: 8 additions & 1 deletion scripts/github_actions/generate_build_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,16 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
if not for_windows
else ["11.7.1", "11.8.0"],
},
"2.1.0": {
"python-version": ["3.8", "3.9", "3.10", "3.11"],
"cuda": ["11.8", "12.1"] # default 12.1
if not for_windows
else ["11.8.0", "12.1.0"],
},
# https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts
}
if test_only_latest_torch:
latest = "2.0.1"
latest = "2.1.0"
matrix = {latest: matrix[latest]}

if for_windows or for_macos:
Expand Down
19 changes: 18 additions & 1 deletion scripts/github_actions/install_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ case "$cuda" in
11.7)
url=https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
;;
11.8)
url=https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
;;
12.1)
url=https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run
;;
*)
echo "Unknown cuda version: $cuda"
exit 1
Expand All @@ -63,10 +69,21 @@ retry curl -LSs -O $url
filename=$(basename $url)
echo "filename: $filename"
chmod +x ./$filename
sudo ./$filename --toolkit --silent

ls -lh
ls -lh /usr/local

sudo ./$filename \
--silent \
--toolkit \
--no-opengl-libs \
--no-drm \
--no-man-page

rm -fv ./$filename

export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
ls -lh $CUDA_HOME
6 changes: 6 additions & 0 deletions scripts/github_actions/install_cudnn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ case $cuda in
11.7)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
11.8)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
12.1)
filename=cudnn-linux-x86_64-8.9.5.29_cuda12-archive.tar.xz
;;
*)
echo "Unsupported cuda version: $cuda"
exit 1
Expand Down
22 changes: 18 additions & 4 deletions scripts/github_actions/install_torch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -x

torch=$TORCH_VERSION
cuda=$CUDA_VERSION
echo "torch: $torch, cuda: $cuda"
if [ x"$TORCH_VERSION" != x"" ] && [ x"$CUDA_VERSION" != x"" ]; then
torch=$TORCH_VERSION
cuda=$CUDA_VERSION
fi

case ${torch} in
1.5.*)
case ${cuda} in
Expand Down Expand Up @@ -171,6 +172,19 @@ case ${torch} in
;;
esac
;;
2.1.*)
case ${cuda} in
11.8)
package="torch==${torch}+cu118"
url=https://download.pytorch.org/whl/torch_stable.html
;;
12.1)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
esac
;;
*)
echo "Unsupported PyTorch version: ${torch}"
exit 1
Expand Down

0 comments on commit 50e2af6

Please sign in to comment.