From 65e9171984cdb54fd8989053f930befac9a5768e Mon Sep 17 00:00:00 2001 From: guyang3532 <62738430+guyang3532@users.noreply.github.com> Date: Tue, 16 Jun 2020 13:22:27 +0800 Subject: [PATCH] WIN smoke test support for nightly package (#456) --- smoke_test.sh | 2 - windows/internal/install_nightly_package.bat | 67 ++++++++++++++++++++ windows/internal/smoke_test.bat | 34 +++++++--- 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 windows/internal/install_nightly_package.bat diff --git a/smoke_test.sh b/smoke_test.sh index 8e3414f7b..0a76942d7 100755 --- a/smoke_test.sh +++ b/smoke_test.sh @@ -78,8 +78,6 @@ if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then elif [[ "$PACKAGE_TYPE" == *wheel ]]; then package_name='torch' -elif [[ "$DESIRED_CUDA" == 'cpu' && "$(uname)" != 'Darwin' ]]; then - package_name='pytorch' else package_name='pytorch' fi diff --git a/windows/internal/install_nightly_package.bat b/windows/internal/install_nightly_package.bat new file mode 100644 index 000000000..7db23ebd6 --- /dev/null +++ b/windows/internal/install_nightly_package.bat @@ -0,0 +1,67 @@ +if "%PACKAGE_TYPE%" == "wheel" goto wheel +if "%PACKAGE_TYPE%" == "conda" goto conda +if "%PACKAGE_TYPE%" == "libtorch" goto libtorch + +:wheel +echo "install pytorch wheel from nightly" + +set pip_url="https://download.pytorch.org/whl/nightly/%DESIRED_CUDA%/torch_nightly.html" +if "%DESIRED_CUDA%" == "cu102" ( + set package_name_and_version="torch==%NIGHTLIES_DATE_PREAMBLE%%DATE%" +) else ( + set package_name_and_version="torch==%NIGHTLIES_DATE_PREAMBLE%%DATE%+%DESIRED_CUDA%" +) +pip install "%package_name_and_version%" -f "%pip_url%" --no-cache-dir --no-index -q +if errorlevel 1 exit /b 1 + +exit /b 0 + +:conda +echo "install pytorch conda from nightly" +set package_name_and_version="pytorch==%NIGHTLIES_DATE_PREAMBLE%%DATE%" + +if "%DESIRED_CUDA%" == "cpu" ( + call conda install -yq -c pytorch-nightly %package_name_and_version% cpuonly +) else ( + call conda install -yq -c pytorch-nightly "cudatoolkit=%CUDA_VERSION_STR%" %package_name_and_version% +) +if ERRORLEVEL 1 exit /b 1 + +FOR /f %%i in ('python -c "import sys;print(sys.version)"') do set cur_python=%%i + +if not %cur_python:~0,3% == %DESIRED_PYTHON% ( + echo "The Python version has changed to %cur_python%" + echo "Probably the package for the version we want does not exist" + echo "conda will change the Python version even if it was explicitly declared" +) + +if "%DESIRED_CUDA%" == "cpu" ( + call conda list torch | findstr cuda || exit /b 0 + echo "The installed package is built for CUDA, the full package is" + call conda list torch +) else ( + call conda list torch | findstr cuda%CUDA_VERSION% && exit /b 0 + echo "The installed package doesn't seem to be built for CUDA "%CUDA_VERSION_STR% + echo "the full package is " + call conda list torch +) +exit /b 1 + +:libtorch +echo "install libtorch from nightly" +if "%LIBTORCH_CONFIG%" == "debug" ( + set NAME_PREFIX=libtorch-win-shared-with-deps-debug +) else ( + set NAME_PREFIX=libtorch-win-shared-with-deps +) +if "%DESIRED_CUDA%" == "cu102" ( + set package_name=%NAME_PREFIX%-%NIGHTLIES_DATE_PREAMBLE%%DATE%.zip +) else ( + set package_name=%NAME_PREFIX%-%NIGHTLIES_DATE_PREAMBLE%%DATE%%%2B%DESIRED_CUDA%.zip +) +set libtorch_url="https://download.pytorch.org/libtorch/nightly/%DESIRED_CUDA%/%package_name%" +curl --retry 3 -k "%libtorch_url%" -o %package_name% +if ERRORLEVEL 1 exit /b 1 + +7z x %package_name% -otmp +if ERRORLEVEL 1 exit /b 1 diff --git a/windows/internal/smoke_test.bat b/windows/internal/smoke_test.bat index d602d17d7..e4e5f7df6 100644 --- a/windows/internal/smoke_test.bat +++ b/windows/internal/smoke_test.bat @@ -49,8 +49,13 @@ set "PATH=%CD%\Python%PYTHON_VERSION%\Scripts;%CD%\Python%PYTHON_VERSION%;%PATH% pip install -q future numpy protobuf six "mkl>=2019" if errorlevel 1 exit /b 1 -for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.whl') do pip install "%%i" -if errorlevel 1 exit /b 1 +if "%TEST_NIGHTLY_PACKAGE%" == "1" ( + call internal\install_nightly_package.bat + if errorlevel 1 exit /b 1 +) else ( + for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.whl') do pip install "%%i" + if errorlevel 1 exit /b 1 +) goto smoke_test @@ -79,16 +84,22 @@ if errorlevel 1 exit /b 1 call conda install -yq future numpy protobuf six if ERRORLEVEL 1 exit /b 1 -for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.tar.bz2') do call conda install -y "%%i" --offline -if ERRORLEVEL 1 exit /b 1 - -if "%CUDA_VERSION%" == "cpu" goto install_cpu_torch - set /a CUDA_VER=%CUDA_VERSION% set CUDA_VER_MAJOR=%CUDA_VERSION:~0,-1% set CUDA_VER_MINOR=%CUDA_VERSION:~-1,1% set CUDA_VERSION_STR=%CUDA_VER_MAJOR%.%CUDA_VER_MINOR% +if "%TEST_NIGHTLY_PACKAGE%" == "1" ( + call internal\install_nightly_package.bat + if errorlevel 1 exit /b 1 + goto smoke_test +) + +for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.tar.bz2') do call conda install -y "%%i" --offline +if ERRORLEVEL 1 exit /b 1 + +if "%CUDA_VERSION%" == "cpu" goto install_cpu_torch + if "%CUDA_VERSION_STR%" == "9.2" ( call conda install -y "cudatoolkit=%CUDA_VERSION_STR%" -c pytorch -c defaults -c numba/label/dev ) else ( @@ -138,8 +149,13 @@ echo "install and test libtorch" if "%VC_YEAR%" == "2017" powershell internal\vs2017_install.ps1 if ERRORLEVEL 1 exit /b 1 -for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *-latest.zip') do 7z x "%%i" -otmp -if ERRORLEVEL 1 exit /b 1 +if "%TEST_NIGHTLY_PACKAGE%" == "1" ( + call internal\install_nightly_package.bat + if errorlevel 1 exit /b 1 +) else ( + for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *-latest.zip') do 7z x "%%i" -otmp + if ERRORLEVEL 1 exit /b 1 +) pushd tmp\libtorch