Skip to content

remove pre-dep torch (fairinternal/xformers#1237) #486

remove pre-dep torch (fairinternal/xformers#1237)

remove pre-dep torch (fairinternal/xformers#1237) #486

Workflow file for this run

name: conda
on:
workflow_dispatch: {}
pull_request:
paths:
- "packaging/**"
- ".github/workflows/conda.yml"
- "setup.py"
- "requirements*.txt"
push:
branches:
- main
tags:
- "v[0-9]+*"
# this yaml file can be cleaned up using yaml anchors, but they're not supported in github actions yet
# https://github.com/actions/runner/issues/1182
env:
MAX_JOBS: 3 # Avoids OOMs
XFORMERS_BUILD_TYPE: "Release"
XFORMERS_PACKAGE_FROM: "conda-${{ github.ref_name }}"
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: "true"
jobs:
build:
strategy:
fail-fast: false
matrix:
python:
- "3.10"
- "3.11"
config:
- torch_version: "2.4.1"
torch_channel: "pytorch"
cuda_version: "12.1.0"
cuda_dep_runtime: ">=12.0,<13.0"
cuda_short_version: "121"
- torch_version: "2.4.1"
torch_channel: "pytorch"
cuda_version: "11.8.0"
cuda_dep_runtime: ">=11.7,<11.9"
cuda_short_version: "118"
name: py${{ matrix.python }}-torch${{ matrix.config.torch_version }}-cu${{ matrix.config.cuda_version }}
runs-on: 8-core-ubuntu # 32GB RAM, 8 vCPUs
container:
image: quay.io/pypa/manylinux_2_28_x86_64
env:
# you need at least cuda 5.0 for some of the stuff compiled here.
TORCH_CUDA_ARCH_LIST: '6.0+PTX 7.0 7.5 8.0+PTX'
timeout-minutes: 360
defaults:
run:
shell: bash
steps:
- if: fromJSON(matrix.config.cuda_short_version) >= 120
run: |
echo "TORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST 9.0a" >> ${GITHUB_ENV}
- name: System info
run: |
pwd
df -h
ldd --version
echo "Memory and swap:"
free -h
echo
swapon --show
- name: Set tag = 'dev'
run: echo "XFORMERS_CONDA_TAG=dev" >> $GITHUB_ENV
- name: Set tag = 'main'
if: startsWith(github.ref, 'refs/tags/v')
run: echo "XFORMERS_CONDA_TAG=main" >> $GITHUB_ENV
- run: echo "${XFORMERS_CONDA_TAG}"
- name: Recursive checkout
uses: actions/checkout@v3
with:
submodules: recursive
path: "."
fetch-depth: 0 # for tags
- name: Install micromamba
shell: bash -l {0}
run: |
set -ex
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
echo "eval \"\$($(pwd)/bin/micromamba shell hook --shell bash)\"" >> ~/.profile
- run: |
micromamba config set channel_priority strict
micromamba create --name env -y anaconda-client conda-build python=${{ matrix.python }} -c anaconda
shell: bash -l {0}
- name: Activate environment
shell: bash -l {0}
run: |
echo "micromamba activate env" >> ~/.profile
echo "==== .profile ====="
cat ~/.profile
- run: which python; which gcc
shell: bash -l {0}
- name: Setup Runner
uses: ./.github/actions/setup-build-cuda
with:
toolkit_type: cuda
toolkit_short_version: ${{ matrix.config.cuda_short_version }}
python: ${{ matrix.python }}
- name: Define version
shell: bash -l {0}
env:
VERSION_SOURCE: ${{ github.ref_type == 'tag' && 'tag' || 'dev' }}
run: |
set -Eeuo pipefail
git config --global --add safe.directory "$(pwd)"
git rev-parse --short HEAD
python -m pip install packaging
version=`python packaging/compute_wheel_version.py --source $VERSION_SOURCE`
echo "BUILD_VERSION=$version" >> ${GITHUB_ENV}
cat ${GITHUB_ENV}
- name: Build & store/upload
shell: bash -l {0}
env:
# NOTE: Ternary operator: ${{ cond && 'trueVal' || 'falseVal' }}
STORE_PT_PACKAGE: ${{ matrix.config.torch_channel != 'pytorch' && '--store-pytorch-package' || '' }}
run: |
anaconda upload --help
python packaging/build_conda.py \
--cuda ${{ matrix.config.cuda_version }} \
--python ${{ matrix.python }} \
--pytorch ${{ matrix.config.torch_version }} \
--pytorch-channel ${{ matrix.config.torch_channel }} \
--cuda-dep-runtime "${{ matrix.config.cuda_dep_runtime }}" \
--store $STORE_PT_PACKAGE
- name: Upload
shell: bash -l {0}
if: github.repository == 'facebookresearch/xformers' && github.event_name != 'pull_request' && matrix.config.torch_channel == 'pytorch'
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: |
# This might fail, let's retry it multiple times
for i in {1..20}
do
[[ $i != 1 ]] && sleep 15
echo "Attempt $i"
anaconda upload --user xformers --label ${XFORMERS_CONDA_TAG} packages/* && break
done
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: linux-py${{ matrix.python }}-torch${{ matrix.config.torch_version }}-cu${{ matrix.config.cuda_short_version }}
path: packages
# Note: it might be helpful to have additional steps that test if the built wheels actually work