From 8847b098bc64a4489d288fe12bd0572e93f19ffa Mon Sep 17 00:00:00 2001 From: agunapal Date: Wed, 27 Sep 2023 17:47:22 +0000 Subject: [PATCH 1/4] Changes for PyTorch 2.1.0 and Python 3.11 --- CONTRIBUTING.md | 4 ++-- README.md | 4 ++-- benchmarks/auto_benchmark.py | 2 +- binaries/conda/build_packages.py | 2 +- docker/README.md | 4 ++-- docker/build_image.sh | 9 ++++++--- docker/build_upload_release.py | 2 +- docker/docker_nightly.py | 2 +- docs/code_coverage.md | 4 ++-- docs/getting_started.md | 4 ++-- requirements/torch_cu121_linux.txt | 7 +++++++ requirements/torch_cu121_windows.txt | 7 +++++++ ts_scripts/install_dependencies.py | 12 +++++++++++- 13 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 requirements/torch_cu121_linux.txt create mode 100644 requirements/torch_cu121_windows.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1bca7ed6e2..b4f441caf8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,9 +20,9 @@ Your contributions will fall into two categories: For GPU ```bash - python ts_scripts/install_dependencies.py --environment=dev --cuda=cu118 + python ts_scripts/install_dependencies.py --environment=dev --cuda=cu121 ``` - > Supported cuda versions as cu118, cu117, cu116, cu113, cu111, cu102, cu101, cu92 + > Supported cuda versions as cu121, cu118, cu117, cu116, cu113, cu111, cu102, cu101, cu92 - Install `pre-commit` to your Git flow: ```bash pre-commit install diff --git a/README.md b/README.md index a5b5a3923b..8aac53f41a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ curl http://127.0.0.1:8080/predictions/bert -T input.txt ``` # Install dependencies # cuda is optional -python ./ts_scripts/install_dependencies.py --cuda=cu102 +python ./ts_scripts/install_dependencies.py --cuda=cu121 # Latest release pip install torchserve torch-model-archiver torch-workflow-archiver @@ -26,7 +26,7 @@ pip install torchserve-nightly torch-model-archiver-nightly torch-workflow-archi ``` # Install dependencies # cuda is optional -python ./ts_scripts/install_dependencies.py --cuda=cu102 +python ./ts_scripts/install_dependencies.py --cuda=cu121 # Latest release conda install -c pytorch torchserve torch-model-archiver torch-workflow-archiver diff --git a/benchmarks/auto_benchmark.py b/benchmarks/auto_benchmark.py index 3e633f8306..3849fdc502 100644 --- a/benchmarks/auto_benchmark.py +++ b/benchmarks/auto_benchmark.py @@ -149,7 +149,7 @@ def install_torchserve(skip_ts_install, hw, ts_version): # install_dependencies.py if hw == "gpu": - cmd = "python ts_scripts/install_dependencies.py --environment dev --cuda cu118" + cmd = "python ts_scripts/install_dependencies.py --environment dev --cuda cu121" elif hw == "neuronx": cmd = "python ts_scripts/install_dependencies.py --environment dev --neuronx" else: diff --git a/binaries/conda/build_packages.py b/binaries/conda/build_packages.py index 037e5ffd34..c2f657b03a 100644 --- a/binaries/conda/build_packages.py +++ b/binaries/conda/build_packages.py @@ -130,7 +130,7 @@ def conda_build( os.environ["PYTHON"] = "python" - python_versions = ["3.8", "3.9", "3.10"] + python_versions = ["3.8", "3.9", "3.10", "3.11"] packages = [os.path.join(conda_build_dir, pkg) for pkg in PACKAGES] # Generate conda binaries for linux-64 diff --git a/docker/README.md b/docker/README.md index df2aea8167..ad7cfd3f43 100644 --- a/docker/README.md +++ b/docker/README.md @@ -37,11 +37,11 @@ Use `build_image.sh` script to build the docker images. The script builds the `p |-bi, --baseimage specify base docker image. Example: nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04| |-bt, --buildtype|Which type of docker image to build. Can be one of : production, dev, ci, codebuild| |-t, --tag|Tag name for image. If not specified, script uses torchserve default tag names.| -|-cv, --cudaversion| Specify to cuda version to use. Supported values `cu92`, `cu101`, `cu102`, `cu111`, `cu113`, `cu116`, `cu117`, `cu118`. Default `cu117`| +|-cv, --cudaversion| Specify to cuda version to use. Supported values `cu92`, `cu101`, `cu102`, `cu111`, `cu113`, `cu116`, `cu117`, `cu118`. `cu121`, Default `cu121`| |-ipex, --build-with-ipex| Specify to build with intel_extension_for_pytorch. If not specified, script builds without intel_extension_for_pytorch.| |-n, --nightly| Specify to build with TorchServe nightly.| |--codebuild| Set if you need [AWS CodeBuild](https://aws.amazon.com/codebuild/)| -|-py, --pythonversion| Specify the python version to use. Supported values `3.8`, `3.9`, `3.10`. Default `3.9`| +|-py, --pythonversion| Specify the python version to use. Supported values `3.8`, `3.9`, `3.10`, `3.11`. Default `3.9`| **PRODUCTION ENVIRONMENT IMAGES** diff --git a/docker/build_image.sh b/docker/build_image.sh index 591c2244e0..96dee3bd05 100755 --- a/docker/build_image.sh +++ b/docker/build_image.sh @@ -82,10 +82,10 @@ do ;; -py|--pythonversion) PYTHON_VERSION="$2" - if [[ $PYTHON_VERSION = 3.8 || $PYTHON_VERSION = 3.9 || $PYTHON_VERSION = 3.10 ]]; then + if [[ $PYTHON_VERSION = 3.8 || $PYTHON_VERSION = 3.9 || $PYTHON_VERSION = 3.10 || $PYTHON_VERSION = 3.11 ]]; then echo "Valid python version" else - echo "Valid python versions are 3.8, 3.9 and 3.10" + echo "Valid python versions are 3.8, 3.9 3.10 and 3.11" exit 1 fi shift @@ -94,7 +94,10 @@ do # With default ubuntu version 20.04 -cv|--cudaversion) CUDA_VERSION="$2" - if [ "${CUDA_VERSION}" == "cu118" ]; + if [ "${CUDA_VERSION}" == "cu121" ]; + then + BASE_IMAGE="nvidia/cuda:12.1.0-base-ubuntu20.04" + elif [ "${CUDA_VERSION}" == "cu118" ]; then BASE_IMAGE="nvidia/cuda:11.8.0-base-ubuntu20.04" elif [ "${CUDA_VERSION}" == "cu117" ]; diff --git a/docker/build_upload_release.py b/docker/build_upload_release.py index e4884f035b..d0343ff0d1 100644 --- a/docker/build_upload_release.py +++ b/docker/build_upload_release.py @@ -28,7 +28,7 @@ # Upload pytorch/torchserve docker binaries try_and_handle(f"./build_image.sh -t {organization}/torchserve:latest", dry_run) try_and_handle( - f"./build_image.sh -g -cv cu118 -t {organization}/torchserve:latest-gpu", + f"./build_image.sh -g -cv cu121 -t {organization}/torchserve:latest-gpu", dry_run, ) try_and_handle( diff --git a/docker/docker_nightly.py b/docker/docker_nightly.py index 36f5079c9d..0522e3f734 100644 --- a/docker/docker_nightly.py +++ b/docker/docker_nightly.py @@ -39,7 +39,7 @@ # Build Nightly images and append the date in the name try_and_handle(f"./build_image.sh -n -t {organization}/{cpu_version}", dry_run) try_and_handle( - f"./build_image.sh -g -cv cu118 -t {organization}/{gpu_version}", + f"./build_image.sh -g -cv cu121 -t {organization}/{gpu_version}", dry_run, ) diff --git a/docs/code_coverage.md b/docs/code_coverage.md index bda87f1d0f..7f5082cc70 100644 --- a/docs/code_coverage.md +++ b/docs/code_coverage.md @@ -10,9 +10,9 @@ For GPU - Install dependencies (if not already installed) ```bash - python ts_scripts/install_dependencies.py --environment=dev --cuda=cu102 + python ts_scripts/install_dependencies.py --environment=dev --cuda=cu121 ``` - > Supported cuda versions as cu118, cu117, cu116, cu113, cu111, cu102, cu101, cu92 + > Supported cuda versions as cu121, cu118, cu117, cu116, cu113, cu111, cu102, cu101, cu92 - Execute sanity suite ```bash diff --git a/docs/getting_started.md b/docs/getting_started.md index 7354f5515b..79b27c4447 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -14,10 +14,10 @@ python ./ts_scripts/install_dependencies.py ``` - - For GPU with Cuda 10.2. Options are `cu92`, `cu101`, `cu102`, `cu111`, `cu113`, `cu116`, `cu117`, `cu118` + - For GPU with Cuda 12.1. Options are `cu92`, `cu101`, `cu102`, `cu111`, `cu113`, `cu116`, `cu117`, `cu118`, `cu121` ```bash - python ./ts_scripts/install_dependencies.py --cuda=cu102 + python ./ts_scripts/install_dependencies.py --cuda=cu121 ``` Note: PyTorch 1.9+ will not support cu92 and cu101. So TorchServe only supports cu92 and cu101 up to PyTorch 1.8.1. diff --git a/requirements/torch_cu121_linux.txt b/requirements/torch_cu121_linux.txt new file mode 100644 index 0000000000..96a61faf09 --- /dev/null +++ b/requirements/torch_cu121_linux.txt @@ -0,0 +1,7 @@ +#pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 +--extra-index-url https://download.pytorch.org/whl/test/cu121 +-r torch_common.txt +torch==2.1.0+cu121; sys_platform == 'linux' +torchvision==0.16.0+cu121; sys_platform == 'linux' +torchtext==0.16.0; sys_platform == 'linux' +torchaudio==2.1.0+cu118; sys_platform == 'linux' diff --git a/requirements/torch_cu121_windows.txt b/requirements/torch_cu121_windows.txt new file mode 100644 index 0000000000..00642e4c8b --- /dev/null +++ b/requirements/torch_cu121_windows.txt @@ -0,0 +1,7 @@ +#pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 +--extra-index-url https://download.pytorch.org/whl/cu121 +-r torch_common.txt +torch==2.1.0+cu121; sys_platform == 'linux' +torchvision==0.16.0+cu121; sys_platform == 'linux' +torchtext==0.16.0; sys_platform == 'linux' +torchaudio==2.1.0+cu121; sys_platform == 'linux' diff --git a/ts_scripts/install_dependencies.py b/ts_scripts/install_dependencies.py index ec404f247c..f816f911c9 100644 --- a/ts_scripts/install_dependencies.py +++ b/ts_scripts/install_dependencies.py @@ -204,7 +204,17 @@ def get_brew_version(): parser.add_argument( "--cuda", default=None, - choices=["cu92", "cu101", "cu102", "cu111", "cu113", "cu116", "cu117", "cu118"], + choices=[ + "cu92", + "cu101", + "cu102", + "cu111", + "cu113", + "cu116", + "cu117", + "cu118", + "cu121", + ], help="CUDA version for torch", ) parser.add_argument( From bb3781da1e7626f7a839d136639f4195b7506dc0 Mon Sep 17 00:00:00 2001 From: agunapal Date: Wed, 27 Sep 2023 18:18:28 +0000 Subject: [PATCH 2/4] Updated workflows with cu121 --- .github/workflows/ci_gpu.yml | 2 +- .github/workflows/regression_tests_gpu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_gpu.yml b/.github/workflows/ci_gpu.yml index 2baec7e16f..4a5bd843a4 100644 --- a/.github/workflows/ci_gpu.yml +++ b/.github/workflows/ci_gpu.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies run: | - python ts_scripts/install_dependencies.py --environment=dev --cuda=cu117 + python ts_scripts/install_dependencies.py --environment=dev --cuda=cu121 - name: Torchserve Sanity uses: nick-fields/retry@v2 with: diff --git a/.github/workflows/regression_tests_gpu.yml b/.github/workflows/regression_tests_gpu.yml index ddfc08670c..49bacbc230 100644 --- a/.github/workflows/regression_tests_gpu.yml +++ b/.github/workflows/regression_tests_gpu.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies run: | - python ts_scripts/install_dependencies.py --environment=dev --cuda=cu117 + python ts_scripts/install_dependencies.py --environment=dev --cuda=cu121 - name: Torchserve Regression Tests run: | python test/regression_tests.py From a72f1c370b16bc65847b984f060367de563ce651 Mon Sep 17 00:00:00 2001 From: agunapal Date: Wed, 27 Sep 2023 19:10:01 +0000 Subject: [PATCH 3/4] update torch audio version --- requirements/torch_cu121_linux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/torch_cu121_linux.txt b/requirements/torch_cu121_linux.txt index 96a61faf09..2065a0a02d 100644 --- a/requirements/torch_cu121_linux.txt +++ b/requirements/torch_cu121_linux.txt @@ -4,4 +4,4 @@ torch==2.1.0+cu121; sys_platform == 'linux' torchvision==0.16.0+cu121; sys_platform == 'linux' torchtext==0.16.0; sys_platform == 'linux' -torchaudio==2.1.0+cu118; sys_platform == 'linux' +torchaudio==2.1.0+cu121; sys_platform == 'linux' From f54c3b7acd5ccdbb93b0df8bf63f225716803d36 Mon Sep 17 00:00:00 2001 From: agunapal Date: Wed, 27 Sep 2023 19:19:08 +0000 Subject: [PATCH 4/4] update torch versions for cpu --- requirements/torch_darwin.txt | 9 +++++---- requirements/torch_linux.txt | 10 +++++----- requirements/torch_windows.txt | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/requirements/torch_darwin.txt b/requirements/torch_darwin.txt index 0e3ff64f98..2566515a1f 100644 --- a/requirements/torch_darwin.txt +++ b/requirements/torch_darwin.txt @@ -1,6 +1,7 @@ #pip install torch torchvision torchaudio +--extra-index-url https://download.pytorch.org/whl/test/cpu -r torch_common.txt -torch==2.0.1; sys_platform == 'darwin' -torchvision==0.15.2; sys_platform == 'darwin' -torchtext==0.15.2; sys_platform == 'darwin' -torchaudio==2.0.2; sys_platform == 'darwin' +torch==2.1.0; sys_platform == 'darwin' +torchvision==0.16.0; sys_platform == 'darwin' +torchtext==0.16.0; sys_platform == 'darwin' +torchaudio==2.1.0; sys_platform == 'darwin' diff --git a/requirements/torch_linux.txt b/requirements/torch_linux.txt index 96424b9ca4..dec184bb54 100644 --- a/requirements/torch_linux.txt +++ b/requirements/torch_linux.txt @@ -1,7 +1,7 @@ #pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu ---extra-index-url https://download.pytorch.org/whl/cpu +--extra-index-url https://download.pytorch.org/whl/test/cpu -r torch_common.txt -torch==2.0.1+cpu; sys_platform == 'linux' -torchvision==0.15.2+cpu; sys_platform == 'linux' -torchtext==0.15.2; sys_platform == 'linux' -torchaudio==2.0.2+cpu; sys_platform == 'linux' +torch==2.1.0+cpu; sys_platform == 'linux' +torchvision==0.16.0+cpu; sys_platform == 'linux' +torchtext==0.16.0; sys_platform == 'linux' +torchaudio==2.1.0+cpu; sys_platform == 'linux' diff --git a/requirements/torch_windows.txt b/requirements/torch_windows.txt index a9ee0f348d..1d13073067 100644 --- a/requirements/torch_windows.txt +++ b/requirements/torch_windows.txt @@ -1,6 +1,7 @@ #pip install torch torchvision torchaudio +--extra-index-url https://download.pytorch.org/whl/test/cpu -r torch_common.txt -torch==2.0.1; sys_platform == 'win32' -torchvision==0.15.2; sys_platform == 'win32' -torchtext==0.15.2; sys_platform == 'win32' -torchaudio==2.0.2; sys_platform == 'win32' +torch==2.1.0; sys_platform == 'win32' +torchvision==0.16.0; sys_platform == 'win32' +torchtext==0.16.0; sys_platform == 'win32' +torchaudio==2.1.0; sys_platform == 'win32'