Skip to content

Commit 03f56ff

Browse files
authored
[CI] Fix windows build (#2760)
1 parent ad7d2a1 commit 03f56ff

File tree

10 files changed

+242
-194
lines changed

10 files changed

+242
-194
lines changed

.github/scripts/version_script.bat

+50
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
11
@echo off
22
set TORCHRL_BUILD_VERSION=0.7.0
33
echo TORCHRL_BUILD_VERSION is set to %TORCHRL_BUILD_VERSION%
4+
5+
@echo on
6+
7+
set VC_VERSION_LOWER=17
8+
set VC_VERSION_UPPER=18
9+
if "%VC_YEAR%" == "2019" (
10+
set VC_VERSION_LOWER=16
11+
set VC_VERSION_UPPER=17
12+
)
13+
if "%VC_YEAR%" == "2017" (
14+
set VC_VERSION_LOWER=15
15+
set VC_VERSION_UPPER=16
16+
)
17+
18+
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [%VC_VERSION_LOWER%^,%VC_VERSION_UPPER%^) -property installationPath`) do (
19+
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" (
20+
set "VS15INSTALLDIR=%%i"
21+
set "VS15VCVARSALL=%%i\VC\Auxiliary\Build\vcvarsall.bat"
22+
goto vswhere
23+
)
24+
)
25+
26+
:vswhere
27+
if "%VSDEVCMD_ARGS%" == "" (
28+
call "%VS15VCVARSALL%" x64 || exit /b 1
29+
) else (
30+
call "%VS15VCVARSALL%" x64 %VSDEVCMD_ARGS% || exit /b 1
31+
)
32+
33+
@echo on
34+
35+
if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
36+
37+
set DISTUTILS_USE_SDK=1
38+
39+
set args=%1
40+
shift
41+
:start
42+
if [%1] == [] goto done
43+
set args=%args% %1
44+
shift
45+
goto start
46+
47+
:done
48+
if "%args%" == "" (
49+
echo Usage: vc_env_helper.bat [command] [args]
50+
echo e.g. vc_env_helper.bat cl /c test.cpp
51+
)
52+
53+
%args% || exit /b 1

.github/unittest/windows_optdepts/scripts/post_process.sh

-3
This file was deleted.

.github/unittest/windows_optdepts/scripts/run_test.sh

-18
This file was deleted.

.github/unittest/windows_optdepts/scripts/setup_env.sh

-45
This file was deleted.

.github/unittest/windows_optdepts/scripts/install.sh .github/unittest/windows_optdepts/scripts/unittest.sh

+41-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
#!/usr/bin/env bash
22

3-
unset PYTORCH_VERSION
4-
# For unittest, nightly PyTorch is used as the following section,
5-
# so no need to set PYTORCH_VERSION.
6-
# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config.
3+
# This script is for setting up environment in which unit test is ran.
4+
# To speed up the CI time, the resulting environment is cached.
5+
#
6+
# Do not install PyTorch and torchvision here, otherwise they also get cached.
77

88
set -ex
9+
# =================================== Setup =================================================
910

1011
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
12+
root_dir="$(git rev-parse --show-toplevel)"
13+
env_dir="${root_dir}/env"
14+
15+
cd "${root_dir}"
16+
17+
eval "$($(which conda) shell.bash hook)" && set -x
18+
19+
# Create test environment at ./env
20+
printf "* Creating a test environment\n"
21+
conda create --name ci -y python="$PYTHON_VERSION"
22+
23+
printf "* Activating the environment"
24+
conda activate ci
25+
26+
printf "Python version"
27+
echo $(which python)
28+
echo $(python --version)
29+
echo $(conda info -e)
30+
31+
32+
python -m pip install hypothesis future cloudpickle pytest pytest-cov pytest-mock pytest-instafail pytest-rerunfailures expecttest pyyaml scipy coverage
33+
34+
# =================================== Install =================================================
1135

12-
eval "$(./conda/Scripts/conda.exe 'shell.bash' 'hook')"
13-
conda activate ./env
1436

1537
# TODO, refactor the below logic to make it easy to understand how to get correct cuda_version.
1638
if [ "${CU_VERSION:-}" == cpu ] ; then
@@ -98,3 +120,16 @@ python -c """
98120
from torchrl.data import ReplayBuffer
99121
print('successfully imported torchrl')
100122
"""
123+
124+
# =================================== Run =================================================
125+
126+
source "$this_dir/set_cuda_envs.sh"
127+
128+
# we don't use torchsnapshot
129+
export CKPT_BACKEND=torch
130+
export MAX_IDLE_COUNT=60
131+
export BATCHED_PIPE_TIMEOUT=60
132+
export LAZY_LEGACY_OP=False
133+
134+
python -m torch.utils.collect_env
135+
pytest --junitxml=test-results/junit.xml -v --durations 200 --ignore test/test_distributed.py --ignore test/test_rlhf.py

.github/workflows/build-wheels-m1.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- repository: pytorch/rl
3535
smoke-test-script: test/smoke_test.py
3636
package-name: torchrl
37-
name: pytorch/rl
37+
name: ${{ matrix.repository }}
3838
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main
3939
with:
4040
repository: ${{ matrix.repository }}

.github/workflows/test-windows-optdepts.yml

+11-13
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,23 @@ permissions:
2121

2222
jobs:
2323
unittests-cpu:
24+
strategy:
25+
matrix:
26+
python-version:
27+
- "3.10"
28+
runner: ["windows.4xlarge"]
29+
gpu-arch-type: ["cpu"]
30+
fail-fast: false
2431
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
2532
with:
26-
runner: "windows.4xlarge"
2733
repository: pytorch/rl
34+
runner: ${{ matrix.runner }}
2835
timeout: 40
36+
test-infra-ref: main
2937
script: |
3038
set -euxo pipefail
3139
32-
export PYTHON_VERSION="3.9"
40+
export PYTHON_VERSION=${{ matrix.python-version }}
3341
export CU_VERSION="cpu"
3442
export torch_cuda="False"
3543
@@ -48,17 +56,7 @@ jobs:
4856
fi
4957
export TD_GET_DEFAULTS_TO_NONE=1
5058
51-
## setup_env.sh
52-
./.github/unittest/windows_optdepts/scripts/setup_env.sh
53-
54-
## install.sh
55-
./.github/unittest/windows_optdepts/scripts/install.sh
56-
57-
## run_test.sh
58-
./.github/unittest/windows_optdepts/scripts/run_test.sh
59-
60-
## post_process.sh
61-
./.github/unittest/windows_optdepts/scripts/post_process.sh
59+
./.github/unittest/windows_optdepts/scripts/unittest.sh
6260
6361
# unittests-gpu:
6462
# uses: pytorch/test-infra/.github/workflows/windows_job.yml@main

.github/workflows/wheels-legacy.yml

-108
This file was deleted.

0 commit comments

Comments
 (0)