-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Junxian Guo
committed
Feb 11, 2025
1 parent
2e56e32
commit 1a170d8
Showing
1 changed file
with
37 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,39 +43,46 @@ jobs: | |
# Using ubuntu-20.04 instead of 22.04 for more compatibility (glibc). Ideally we'd use the | ||
# manylinux docker image, but I haven't figured out how to install CUDA on manylinux. | ||
os: [ubuntu-20.04] | ||
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||
torch-version: ['2.2.2', '2.3.1', '2.4.0', '2.5.1', '2.6.0'] | ||
cuda-version: ['12.4.1'] | ||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] | ||
torch-version: ['1.12.1', '1.13.1', '2.0.1', '2.1.1', '2.2.0'] | ||
cuda-version: ['11.8.0', '12.2.0'] | ||
# We need separate wheels that either uses C++11 ABI (-D_GLIBCXX_USE_CXX11_ABI) or not. | ||
# Pytorch wheels currently don't use it, but nvcr images have Pytorch compiled with C++11 ABI. | ||
# Without this we get import error (undefined symbol: _ZN3c105ErrorC2ENS_14SourceLocationESs) | ||
# when building without C++11 ABI and using it on nvcr images. | ||
cxx11_abi: ['FALSE', 'TRUE'] | ||
exclude: | ||
# see https://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix | ||
# Pytorch < 2.5 does not support Python 3.13 | ||
- torch-version: '2.2.2' | ||
python-version: '3.13' | ||
- torch-version: '2.3.1' | ||
python-version: '3.13' | ||
- torch-version: '2.4.0' | ||
python-version: '3.13' | ||
# Pytorch <= 1.12 does not support Python 3.11 | ||
- torch-version: '1.12.1' | ||
python-version: '3.11' | ||
# Pytorch >= 2.0 only supports Python >= 3.8 | ||
- torch-version: '2.0.1' | ||
python-version: '3.7' | ||
- torch-version: '2.1.1' | ||
python-version: '3.7' | ||
- torch-version: '2.2.0' | ||
python-version: '3.7' | ||
# Pytorch <= 2.0 only supports CUDA <= 11.8 | ||
- torch-version: '1.12.1' | ||
cuda-version: '12.2.0' | ||
- torch-version: '1.13.1' | ||
cuda-version: '12.2.0' | ||
- torch-version: '2.0.1' | ||
cuda-version: '12.2.0' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Set CUDA and PyTorch versions | ||
run: | | ||
echo "MATRIX_CUDA_VERSION=$(echo ${{ matrix.cuda-version }} | awk -F \. {'print $1 $2'})" >> $GITHUB_ENV | ||
echo "MATRIX_TORCH_VERSION=$(echo ${{ matrix.torch-version }} | awk -F \. {'print $1 "." $2'})" >> $GITHUB_ENV | ||
echo "WHEEL_CUDA_VERSION=$(echo ${{ matrix.cuda-version }} | awk -F \. {'print $1'})" >> $GITHUB_ENV | ||
echo "MATRIX_PYTHON_VERSION=$(echo ${{ matrix.python-version }} | awk -F \. {'print $1 $2'})" >> $GITHUB_ENV | ||
- name: Free up disk space | ||
if: ${{ runner.os == 'Linux' }} | ||
|
@@ -94,40 +101,30 @@ jobs: | |
|
||
- name: Install CUDA ${{ matrix.cuda-version }} | ||
if: ${{ matrix.cuda-version != 'cpu' }} | ||
uses: Jimver/[email protected].19 | ||
uses: Jimver/[email protected].11 | ||
id: cuda-toolkit | ||
with: | ||
cuda: ${{ matrix.cuda-version }} | ||
linux-local-args: '["--toolkit"]' | ||
# default method is "local", and we're hitting some error with caching for CUDA 11.8 and 12.1 | ||
# method: ${{ (matrix.cuda-version == '11.8.0' || matrix.cuda-version == '12.1.0') && 'network' || 'local' }} | ||
method: 'network' | ||
sub-packages: '["nvcc"]' | ||
# We need the cuda libraries (e.g. cuSparse, cuSolver) for compiling PyTorch extensions, | ||
# not just nvcc | ||
# sub-packages: '["nvcc"]' | ||
|
||
- name: Install PyTorch ${{ matrix.torch-version }}+cu${{ matrix.cuda-version }} | ||
run: | | ||
pip install --upgrade pip | ||
# For some reason torch 2.2.0 on python 3.12 errors saying no setuptools | ||
pip install setuptools==75.8.0 | ||
# With python 3.13 and torch 2.5.1, unless we update typing-extensions, we get error | ||
# AttributeError: attribute '__default__' of 'typing.ParamSpec' objects is not writable | ||
pip install typing-extensions==4.12.2 | ||
# If we don't install before installing Pytorch, we get error for torch 2.0.1 | ||
# ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none) | ||
pip install lit | ||
# We want to figure out the CUDA version to download pytorch | ||
# e.g. we can have system CUDA version being 11.7 but if torch==1.12 then we need to download the wheel from cu116 | ||
# see https://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix | ||
# This code is ugly, maybe there's a better way to do this. | ||
export TORCH_CUDA_VERSION=$(python -c "from os import environ as env; \ | ||
minv = {'2.2': 118, '2.3': 118, '2.4': 118, '2.5': 118, '2.6': 118}[env['MATRIX_TORCH_VERSION']]; \ | ||
maxv = {'2.2': 121, '2.3': 121, '2.4': 124, '2.5': 124, '2.6': 124}[env['MATRIX_TORCH_VERSION']]; \ | ||
print(minv if int(env['MATRIX_CUDA_VERSION']) < 120 else maxv)" \ | ||
) | ||
export TORCH_CUDA_VERSION=$(python -c "import os; minv = {'1.12': 113, '1.13': 116, '2.0': 117, '2.1': 118, '2.2': 118}[os.environ['MATRIX_TORCH_VERSION']]; maxv = {'1.12': 116, '1.13': 117, '2.0': 118, '2.1': 121, '2.2': 121}[os.environ['MATRIX_TORCH_VERSION']]; print(max(min(int(os.environ['MATRIX_CUDA_VERSION']), maxv), minv))") | ||
if [[ ${{ matrix.torch-version }} == *"dev"* ]]; then | ||
# pip install --no-cache-dir --pre torch==${{ matrix.torch-version }} --index-url https://download.pytorch.org/whl/nightly/cu${TORCH_CUDA_VERSION} | ||
# Can't use --no-deps because we need cudnn etc. | ||
# Hard-coding this version of pytorch-triton for torch 2.6.0.dev20241001 | ||
pip install jinja2 | ||
pip install https://download.pytorch.org/whl/nightly/pytorch_triton-3.1.0%2Bcf34004b8a-cp${MATRIX_PYTHON_VERSION}-cp${MATRIX_PYTHON_VERSION}-linux_x86_64.whl | ||
pip install --no-cache-dir --pre https://download.pytorch.org/whl/nightly/cu${TORCH_CUDA_VERSION}/torch-${{ matrix.torch-version }}%2Bcu${TORCH_CUDA_VERSION}-cp${MATRIX_PYTHON_VERSION}-cp${MATRIX_PYTHON_VERSION}-linux_x86_64.whl | ||
pip install --no-cache-dir --pre torch==${{ matrix.torch-version }} --index-url https://download.pytorch.org/whl/nightly/cu${TORCH_CUDA_VERSION} | ||
else | ||
pip install --no-cache-dir torch==${{ matrix.torch-version }} --index-url https://download.pytorch.org/whl/cu${TORCH_CUDA_VERSION} | ||
fi | ||
|
@@ -144,14 +141,13 @@ jobs: | |
# We want setuptools >= 49.6.0 otherwise we can't compile the extension if system CUDA version is 11.7 and pytorch cuda version is 11.6 | ||
# https://github.com/pytorch/pytorch/blob/664058fa83f1d8eede5d66418abff6e20bd76ca8/torch/utils/cpp_extension.py#L810 | ||
# However this still fails so I'm using a newer version of setuptools | ||
pip install setuptools==75.8.0 | ||
pip install setuptools==68.0.0 | ||
pip install ninja packaging wheel | ||
export PATH=/usr/local/nvidia/bin:/usr/local/nvidia/lib64:$PATH | ||
export LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH | ||
# Limit MAX_JOBS otherwise the github runner goes OOM | ||
# nvcc 11.8 can compile with 2 jobs, but nvcc 12.3 goes OOM | ||
MAX_JOBS=$([ "$MATRIX_CUDA_VERSION" == "123" ] && echo 1 || echo 2) FLASH_ATTENTION_FORCE_BUILD="TRUE" FLASH_ATTENTION_FORCE_CXX11_ABI=${{ matrix.cxx11_abi}} python setup.py bdist_wheel --dist-dir=dist | ||
tmpname=cu${WHEEL_CUDA_VERSION}torch${MATRIX_TORCH_VERSION}cxx11abi${{ matrix.cxx11_abi }} | ||
MAX_JOBS=2 FLASH_ATTENTION_FORCE_BUILD="TRUE" FLASH_ATTENTION_FORCE_CXX11_ABI=${{ matrix.cxx11_abi}} python setup.py bdist_wheel --dist-dir=dist | ||
tmpname=cu${MATRIX_CUDA_VERSION}torch${MATRIX_TORCH_VERSION}cxx11abi${{ matrix.cxx11_abi }} | ||
wheel_name=$(ls dist/*whl | xargs -n 1 basename | sed "s/-/+$tmpname-/2") | ||
ls dist/*whl |xargs -I {} mv {} dist/${wheel_name} | ||
echo "wheel_name=${wheel_name}" >> $GITHUB_ENV | ||
|
@@ -190,17 +186,15 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v5 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install ninja packaging wheel twine | ||
# Install latest setuptools with support for pypi metadata 2.2 (improved compat w/ uv) | ||
pip install setuptools==75.8.0 | ||
pip install ninja packaging setuptools wheel twine | ||
# We don't want to download anything CUDA-related here | ||
pip install torch --index-url https://download.pytorch.org/whl/cpu | ||
|