diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index 1545a4e02..51c8d4365 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -28,129 +28,356 @@ concurrency: cancel-in-progress: true jobs: - build-wheel: + build-wheel-linux: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' runs-on: ubuntu-20.04 - defaults: - run: - shell: bash -l {0} strategy: matrix: - python: - - version: "3.8" - tag: py38 - - version: "3.9" - tag: py39 - - version: "3.10" - tag: py310 + python_version: [["3.7", "cp37-cp37m"], ["3.8", "cp38-cp38"], ["3.9", "cp39-cp39"], ["3.10", "cp310-cp310"]] + cuda_support: [["", "cpu", "cpu"]] + container: pytorch/manylinux-cuda116 steps: - - name: Checkout tensordict + - name: Checkout torchrl uses: actions/checkout@v2 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: build_binary - python-version: ${{ matrix.python.version }} + env: + AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache" - name: Install PyTorch nightly - run: python -m pip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu - - name: Build TensorDict Nightly + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/${{ matrix.cuda_support[1] }} + - name: Build TorchRL Nightly run: | rm -r dist || true - python -m pip install wheel - python setup.py bdist_wheel \ - --package_name tensordict-nightly \ - --python-tag=${{ matrix.python.tag }} + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install wheel + python3 setup.py bdist_wheel \ + --package_name torchrl-nightly \ + --python-tag=${{ matrix.python-tag }} + find dist -name '*whl' -exec bash -c ' mv $0 ${0/linux/manylinux1}' {} \; + # pytorch/pytorch binaries are also manylinux_2_17 compliant but they + # pretend that they're manylinux1 compliant so we do the same. + - name: Show auditwheel output; confirm 2-17 + run: | + python3 -mpip install auditwheel + auditwheel show dist/* - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: - name: tensordict-nightly-${{ matrix.python.version }}.whl + name: torchrl-linux-${{ matrix.python_version[0] }}_${{ matrix.cuda_support[2] }}.whl path: dist/*.whl - test-wheel: - needs: build-wheel + build-wheel-mac: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + runs-on: macos-latest strategy: matrix: - os: ["ubuntu-20.04", "macos-latest"] - python: - - version: "3.8" - tag: py38 - - version: "3.9" - tag: py39 - - version: "3.10" - tag: py310 - runs-on: ${{ matrix.os }} + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] steps: - - name: Checkout TensorDict - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python.version }} + python-version: ${{ matrix.python_version[1] }} architecture: x64 - - name: Upgrade pip + - name: Checkout torchrl + uses: actions/checkout@v2 + - name: Install PyTorch nightly run: | - python -m pip install --upgrade pip + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu + - name: Build TorchRL Nightly + run: | + rm -r dist || true + export CC=clang CXX=clang++ + python3 -mpip install wheel + python3 setup.py bdist_wheel \ + --package_name torchrl-nightly \ + --python-tag=${{ matrix.python-tag }} + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: torchrl-mac-${{ matrix.python_version[0] }}.whl + path: dist/*.whl + + test-wheel-mac: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: build-wheel-mac + runs-on: macos-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + architecture: x64 + - name: Checkout tensordict + uses: actions/checkout@v2 - name: Install PyTorch Nightly run: | - python -m pip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu - name: Upgrade pip run: | - python -m pip install --upgrade pip + python3 -mpip install --upgrade pip - name: Install test dependencies run: | - python -m pip install numpy pytest --no-cache-dir + python3 -mpip install numpy pytest --no-cache-dir - name: Download built wheels uses: actions/download-artifact@v2 with: - name: tensordict-nightly-${{ matrix.python.version }}.whl + name: tensordict-mac-${{ matrix.python_version[0] }}.whl path: /tmp/wheels - name: Install built wheels run: | - python -m pip install /tmp/wheels/* + python3 -mpip install /tmp/wheels/* - name: Log version string run: | # Avoid ambiguity of "import tensordict" by deleting the source files. rm -rf tensordict/ - python -c "import tensordict; print(tensordict.__version__)" + python3 -c "import tensordict; print(tensordict.__version__)" - name: Run tests run: | set -e export IN_CI=1 mkdir test-reports python -m torch.utils.collect_env - python -c "import tensordict; print(tensordict.__version__);from tensordict import TensorDict" + python -c "import tensordict; print(tensordict.__version__);from tensordict.data import ReplayBuffer" EXIT_STATUS=0 - pytest test/smoke_test.py -v --durations 20 + pytest test/smoke_test.py -v --durations 200 exit $EXIT_STATUS - upload-wheel: - if: github.repository_owner == 'pytorch-labs' - needs: test-wheel + upload-wheel-linux: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: test-wheel-linux runs-on: ubuntu-20.04 strategy: matrix: - python: - - version: "3.8" - tag: py39 - - version: "3.9" - tag: py39 - - version: "3.10" - tag: py310 + python_version: [["3.7", "cp37-cp37m"], ["3.8", "cp38-cp38"], ["3.9", "cp39-cp39"], ["3.10", "cp310-cp310"]] + cuda_support: [["", "cpu", "cpu"]] + container: pytorch/manylinux-${{ matrix.cuda_support[2] }} steps: - - name: Checkout TensorDict + - name: Checkout tensordict uses: actions/checkout@v2 - name: Download built wheels uses: actions/download-artifact@v2 with: - name: tensordict-nightly-${{ matrix.python.version }}.whl + name: tensordict-linux-${{ matrix.python_version[0] }}_${{ matrix.cuda_support[2] }}.whl path: /tmp/wheels - - name: Push TensorDict Binary to PYPI + - name: Push tensordict Binary to PYPI env: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} run: | - python -m pip install twine + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install twine python -m twine upload \ --username __token__ \ --password "$PYPI_TOKEN" \ --skip-existing \ /tmp/wheels/tensordict_nightly-*.whl \ --verbose + + upload-wheel-mac: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: test-wheel-mac + runs-on: macos-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Download built wheels + uses: actions/download-artifact@v2 + with: + name: tensordict-mac-${{ matrix.python_version[0] }}.whl + path: /tmp/wheels + - name: Push tensordict Binary to PYPI + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + python3 -mpip install twine + python3 -m twine upload \ + --username __token__ \ + --password "$PYPI_TOKEN" \ + --skip-existing \ + /tmp/wheels/tensordict_nightly-*.whl \ + --verbose + + test-wheel-linux: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: build-wheel-linux + runs-on: ubuntu-20.04 + strategy: + matrix: + python_version: [["3.7", "cp37-cp37"], ["3.8", "cp38-cp38"], ["3.9", "cp39-cp39"], ["3.10", "cp310-cp310"]] + cuda_support: [["", "cpu", "cpu"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[0] }} + architecture: x64 + env: + AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache" + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch Nightly + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/${{ matrix.cuda_support[1] }} + - name: Upgrade pip + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install --upgrade pip + - name: Install test dependencies + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install numpy pytest pillow>=4.1.1 scipy networkx expecttest pyyaml + - name: Download built wheels + uses: actions/download-artifact@v2 + with: + name: tensordict-linux-${{ matrix.python_version[0] }}_${{ matrix.cuda_support[2] }}.whl + path: /tmp/wheels + env: + AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache" + - name: Install built wheels + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install /tmp/wheels/* + - name: Log version string + run: | + # Avoid ambiguity of "import tensordict" by deleting the source files. + rm -rf tensordict/ + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -c "import tensordict; print(tensordict.__version__)" + - name: Run tests + run: | + set -e + export IN_CI=1 + mkdir test-reports + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -m torch.utils.collect_env + python3 -c "import tensordict; print(tensordict.__version__);from tensordict.data import ReplayBuffer" + EXIT_STATUS=0 + pytest test/smoke_test.py -v --durations 200 + exit $EXIT_STATUS + + build-wheel-windows: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + runs-on: windows-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch nightly + shell: bash + run: | + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu + - name: Build tensordict nightly + shell: bash + run: | + rm -r dist || true + python3 -mpip install wheel + python3 setup.py bdist_wheel \ + --package_name tensordict-nightly \ + --python-tag=${{ matrix.python-tag }} + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: tensordict-win-${{ matrix.python_version[0] }}.whl + path: dist/*.whl + + test-wheel-windows: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: build-wheel-windows + runs-on: windows-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch Nightly + shell: bash + run: | + python3 -mpip install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu + - name: Upgrade pip + shell: bash + run: | + python3 -mpip install --upgrade pip + - name: Install test dependencies + shell: bash + run: | + python3 -mpip install numpy pytest --no-cache-dir + - name: Download built wheels + uses: actions/download-artifact@v2 + with: + name: tensordict-win-${{ matrix.python_version[0] }}.whl + path: wheels + - name: Install built wheels + shell: bash + run: | + python3 -mpip install wheels/* + - name: Log version string + shell: bash + run: | + # Avoid ambiguity of "import tensordict" by deleting the source files. + rm -rf tensordict/ + python3 -c "import tensordict; print(tensordict.__version__)" + - name: Run tests + shell: bash + run: | + set -e + export IN_CI=1 + mkdir test-reports + python -m torch.utils.collect_env + python -c "import tensordict; print(tensordict.__version__);from tensordict.data import ReplayBuffer" + EXIT_STATUS=0 + pytest test/smoke_test.py -v --durations 200 + exit $EXIT_STATUS + + upload-wheel-windows: + # Don't run on forked repos. + if: github.repository_owner == 'pytorch' + needs: test-wheel-windows + runs-on: windows-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Download built wheels + uses: actions/download-artifact@v2 + with: + name: tensordict-win-${{ matrix.python_version[0] }}.whl + path: wheels + - name: Push tensordict Binary to PYPI + shell: bash + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + python3 -mpip install twine + python3 -m twine upload \ + --username __token__ \ + --password "$PYPI_TOKEN" \ + --skip-existing \ + wheels/tensordict_nightly-*.whl \ + --verbose diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index cc28371e0..305bc291c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -4,7 +4,7 @@ on: types: [opened, synchronize, reopened] push: branches: - - release/0.1.2 + - release/0.1.3 concurrency: # Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}. @@ -13,90 +13,200 @@ concurrency: cancel-in-progress: true jobs: - build-wheel: + + build-wheel-linux: runs-on: ubuntu-20.04 - defaults: - run: - shell: bash -l {0} strategy: matrix: - python: - - version: "3.8" - tag: py38 - - version: "3.9" - tag: py39 - - version: "3.10" - tag: py310 + python_version: [["3.7", "cp37-cp37m"], ["3.8", "cp38-cp38"], ["3.9", "cp39-cp39"], ["3.10", "cp310-cp310"]] + cuda_support: [["", "--extra-index-url https://download.pytorch.org/whl/cpu", "\"['cpu', '11.3', '11.6']\"", "cpu"]] + container: pytorch/manylinux-${{ matrix.cuda_support[3] }} steps: - name: Checkout tensordict uses: actions/checkout@v2 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2 + - name: Install PyTorch RC + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install torch ${{ matrix.cuda_support[1] }} + - name: Build wheel + run: | + export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" + python3 -mpip install wheel + BUILD_VERSION=0.1.3 python3 setup.py bdist_wheel + # NB: wheels have the linux_x86_64 tag so we rename to manylinux1 + # find . -name 'dist/*whl' -exec bash -c ' mv $0 ${0/linux/manylinux1}' {} \; + # pytorch/pytorch binaries are also manylinux_2_17 compliant but they + # pretend that they're manylinux1 compliant so we do the same. + - name: Show auditwheel output; confirm 2-17 + run: | + python3 -mpip install auditwheel + auditwheel show dist/* + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: tensordict-linux-${{ matrix.python_version[0] }}.whl + path: dist/tensordict-*.whl + - name: Upload wheel for download + uses: actions/upload-artifact@v2 with: - activate-environment: build_binary - python-version: ${{ matrix.python.version }} - - name: Check Python version + name: tensordict-batch.whl + path: dist/*.whl + + build-wheel-mac: + runs-on: macos-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + architecture: x64 + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch RC run: | - python --version - - name: Install PyTorch + python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + - name: Build wheel run: | - python -m pip install torch - python -m pip install "git+https://github.com/pytorch/functorch.git@release/0.2" + export CC=clang CXX=clang++ + python3 -mpip install wheel + BUILD_VERSION=0.1.3 python3 setup.py bdist_wheel + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: tensordict-mac-${{ matrix.python_version[0] }}.whl + path: dist/tensordict-*.whl + - name: Upload wheel for download + uses: actions/upload-artifact@v2 + with: + name: tensordict-batch.whl + path: dist/*.whl + + build-wheel-windows: + runs-on: windows-latest + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch RC + shell: bash + run: | + python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu - name: Build wheel + shell: bash run: | - python -m pip install wheel - BUILD_VERSION=0.1.2 python setup.py bdist_wheel + python3 -mpip install wheel + BUILD_VERSION=0.1.3 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: - name: tensordict-${{ matrix.python.tag }}.whl + name: tensordict-win-${{ matrix.python_version[0] }}.whl path: dist/tensordict-*.whl + - name: Upload wheel for download + uses: actions/upload-artifact@v2 + with: + name: tensordict-batch.whl + path: dist/*.whl + test-wheel: - needs: build-wheel + needs: [build-wheel-linux, build-wheel-mac] strategy: matrix: - os: ["ubuntu-20.04", "macos-latest"] - python: - - version: "3.8" - tag: py38 - - version: "3.9" - tag: py39 - - version: "3.10" - tag: py310 - runs-on: ${{ matrix.os }} + os: [["linux", "ubuntu-20.04"], ["mac", "macos-latest"]] + python_version: [ "3.7", "3.8", "3.9", "3.10" ] + runs-on: ${{ matrix.os[1] }} steps: - - name: Checkout Tensordict - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python.version }} + python-version: ${{ matrix.python_version }} architecture: x64 - - name: Upgrade pip + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch RC run: | - python -m pip install --upgrade pip - - name: Install PyTorch + python3 -mpip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu + - name: Upgrade pip run: | - python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu - python -m pip install "git+https://github.com/pytorch/functorch.git@release/0.2" + python3 -mpip install --upgrade pip - name: Install test dependencies run: | - python -m pip install numpy pytest pytest-cov codecov unittest-xml-reporting pillow>=4.1.1 scipy av networkx expecttest pyyaml + python3 -mpip install numpy pytest pytest-cov codecov unittest-xml-reporting pillow>=4.1.1 scipy av networkx expecttest pyyaml - name: Download built wheels uses: actions/download-artifact@v2 with: - name: tensordict-${{ matrix.python.tag }}.whl + name: tensordict-${{ matrix.os[0] }}-${{ matrix.python_version }}.whl path: /tmp/wheels - name: Install built wheels run: | - python -m pip install /tmp/wheels/* + python3 -mpip install /tmp/wheels/* + - name: Log version string + run: | + # Avoid ambiguity of "import tensordict" by deleting the source files. + rm -rf tensordict/ + python -c "import tensordict; print(tensordict.__version__)" + - name: Run tests + run: | + set -e + export IN_CI=1 + mkdir test-reports + python -m torch.utils.collect_env + python -c "import tensordict; print(tensordict.__version__)" + EXIT_STATUS=0 + pytest test/smoke_test.py -v --durations 200 + exit $EXIT_STATUS + + test-wheel-windows: + needs: build-wheel-windows + strategy: + matrix: + python_version: [ "3.7", "3.8", "3.9", "3.10" ] + runs-on: windows-latest + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version }} + - name: Checkout tensordict + uses: actions/checkout@v2 + - name: Install PyTorch RC + shell: bash + run: | + python3 -mpip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu + - name: Upgrade pip + shell: bash + run: | + python3 -mpip install --upgrade pip + - name: Install test dependencies + shell: bash + run: | + python3 -mpip install numpy pytest pytest-cov codecov unittest-xml-reporting pillow>=4.1.1 scipy av networkx expecttest pyyaml + - name: Download built wheels + uses: actions/download-artifact@v2 + with: + name: tensordict-win-${{ matrix.python_version }}.whl + path: wheels + - name: Install built wheels + shell: bash + run: | + python3 -mpip install wheels/* - name: Log version string + shell: bash run: | # Avoid ambiguity of "import tensordict" by deleting the source files. rm -rf tensordict/ python -c "import tensordict; print(tensordict.__version__)" - name: Run tests + shell: bash run: | set -e export IN_CI=1 @@ -104,5 +214,5 @@ jobs: python -m torch.utils.collect_env python -c "import tensordict; print(tensordict.__version__)" EXIT_STATUS=0 - pytest test/smoke_test.py -v --durations 20 + pytest test/smoke_test.py -v --durations 200 exit $EXIT_STATUS