Skip to content

Commit

Permalink
disable cuda-ext by default (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
robotcator authored Oct 24, 2024
1 parent d7307e0 commit bc9857e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 136 deletions.
152 changes: 20 additions & 132 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,144 +1,32 @@
# This workflow will upload a Python Package to Release asset
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries


name: Python Package
name: Publish Package

on:
create:
tags:
- '**'
push:
branches:
- main

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Get the tag version
id: extract_branch
run: echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
shell: bash
publish_package:
name: Publish package

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
release_name: ${{ steps.extract_branch.outputs.branch }}

wheel:
name: Build Wheel
runs-on: ${{ matrix.os }}
needs: release

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
python-version: ['3.7', '3.8', '3.9', '3.10']
torch-version: [1.12.0, 1.12.1, 1.13.1, 2.0.0]
cuda-version: ['113', '116', '117', '118']
exclude:
- torch-version: 1.12.0
cuda-version: '117'
- torch-version: 1.12.0
cuda-version: '118'
- torch-version: 1.12.1
cuda-version: '117'
- torch-version: 1.12.1
cuda-version: '118'
- torch-version: 1.13.1
cuda-version: '113'
- torch-version: 1.13.1
cuda-version: '118'
- torch-version: 2.0.0
python-version: '3.7'
- torch-version: 2.0.0
cuda-version: '113'
- torch-version: 2.0.0
cuda-version: '116'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Set up Linux Env
if: ${{ runner.os == 'Linux' }}
run: |
sudo rm -rf /usr/share/dotnet
bash .github/workflows/env.sh
echo ${{ needs.create_release.outputs.upload_url }}
echo ${{ needs.steps.extract_branch.outputs.upload_url }}
shell:
bash
- uses: actions/checkout@v3

- name: Install CUDA ${{ matrix.cuda-version }}
if: ${{ matrix.cuda-version != 'cpu' }}
run: |
bash .github/workflows/cuda/cu${{ matrix.cuda-version }}-${{ runner.os }}.sh
shell:
bash

- name: Check GPU Env
if: ${{ matrix.cuda-version != 'cpu' }}
run: |
source .github/workflows/cuda/cu${{ matrix.cuda-version }}-${{ runner.os }}-env.sh
nvcc --version
shell:
bash
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install PyTorch ${{ matrix.torch-version }}+cu${{ matrix.cuda-version }}
- name: Build core package
env:
FLASH_ATTENTION_SKIP_CUDA_BUILD: "TRUE"
run: |
pip install numpy pyyaml scipy ipython mkl mkl-include ninja cython typing pandas typing-extensions dataclasses && conda clean -ya
pip install torch==${{ matrix.torch-version }}+cu${{ matrix.cuda-version }} --extra-index-url https://download.pytorch.org/whl/cu${{ matrix.cuda-version }}
python --version
python -c "import torch; print('PyTorch:', torch.__version__)"
python -c "import torch; print('CUDA:', torch.version.cuda)"
python -c "from torch.utils import cpp_extension; print (cpp_extension.CUDA_HOME)"
shell:
bash

- name: Get the tag version
id: extract_branch
run: echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
pip install setuptools wheel twine
python setup.py sdist --dist-dir=dist
- name: Get Release with tag
id: get_current_release
uses: joutvhu/get-release@v1
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
- name: Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build wheel
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
export FORCE_CUDA="1"
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
export CUDA_INSTALL_DIR=/usr/local/cuda-11.3$CUDA_INSTALL_DIR
pip install wheel
python setup.py bdist_wheel --dist-dir=dist
tmpname=cu${{ matrix.cuda-version }}torch${{ matrix.torch-version }}
wheel_name=$(ls dist/*whl | xargs -n 1 basename | sed "s/-/+$tmpname-/2")
ls dist/*whl |xargs -I {} mv {} ${wheel_name}
echo "wheel_name=${wheel_name}" >> $GITHUB_ENV
- name: Upload Release Asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# why didn't works
upload_url: ${{ steps.get_current_release.outputs.upload_url }}
asset_path: ./${{env.wheel_name}}
asset_name: ${{env.wheel_name}}
asset_content_type: application/*
python -m twine upload dist/*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include unicore/version.txt
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from setuptools import find_packages, setup

DISABLE_CUDA_EXTENSION = False
DISABLE_CUDA_EXTENSION = True
filtered_args = []
for i, arg in enumerate(sys.argv):
if arg == '--disable-cuda-ext':
DISABLE_CUDA_EXTENSION = True
if arg == '--enable-cuda-ext':
DISABLE_CUDA_EXTENSION = False
continue
filtered_args.append(arg)
sys.argv = filtered_args
Expand Down Expand Up @@ -242,8 +242,8 @@ def check_cuda_torch_binary_vs_bare_metal(cuda_dir):
install_requires=[
'numpy; python_version>="3.7"',
"lmdb",
"torch>=2.0.0",
"tqdm",
"torch>=2.0.0",
"ml_collections",
"scipy",
"tensorboardX",
Expand Down

1 comment on commit bc9857e

@hughplay
Copy link

@hughplay hughplay commented on bc9857e Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For such a modification to a default parameter, it should at least be declared in the README. Otherwise, it wastes everyone's time trying to figure out why a previously working Dockerfile and code suddenly stop working. @robotcator

Please sign in to comment.