From c9b4a44c7db3921c1216d5ad4e417599d82e8bcd Mon Sep 17 00:00:00 2001 From: Ruilong Li <397653553@qq.com> Date: Thu, 12 Oct 2023 18:29:26 -0700 Subject: [PATCH 1/2] workflow for pypi publish --- .github/workflows/publish.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..f8070aed6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,33 @@ +# This workflows will upload a Python Package using twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + environment: production + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.7' + - name: Install dependencies + run: | + python -m pip install build twine + - name: Strip unsupported tags in README + run: | + sed -i '//,//d' README.md + - name: Build and publish + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + BUILD_NO_CUDA=1 python -m build + twine upload --username __token__ --password $PYPI_TOKEN dist/* \ No newline at end of file From 62e83dc1378580225d3e64e2cc028ad7f502179c Mon Sep 17 00:00:00 2001 From: Ruilong Li <397653553@qq.com> Date: Fri, 13 Oct 2023 09:56:29 -0700 Subject: [PATCH 2/2] workflow for building wheels on github --- .github/workflows/building.yml | 139 +++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 .github/workflows/building.yml diff --git a/.github/workflows/building.yml b/.github/workflows/building.yml new file mode 100644 index 000000000..4ec00b5af --- /dev/null +++ b/.github/workflows/building.yml @@ -0,0 +1,139 @@ +name: Building Wheels + +on: [workflow_dispatch] + +jobs: + + wheel: + runs-on: ${{ matrix.os }} + environment: production + + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, windows-2019] + # support version based on: https://download.pytorch.org/whl/torch/ + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + torch-version: [1.11.0, 1.12.0, 1.13.0, 2.0.0] + cuda-version: ['cu113', 'cu115', 'cu116', 'cu117', 'cu118'] + exclude: + - torch-version: 1.11.0 + python-version: '3.11' + - torch-version: 1.11.0 + cuda-version: 'cu116' + - torch-version: 1.11.0 + cuda-version: 'cu117' + - torch-version: 1.11.0 + cuda-version: 'cu118' + + - torch-version: 1.12.0 + python-version: '3.11' + - torch-version: 1.12.0 + cuda-version: 'cu115' + - torch-version: 1.12.0 + cuda-version: 'cu117' + - torch-version: 1.12.0 + cuda-version: 'cu118' + + - torch-version: 1.13.0 + cuda-version: 'cu102' + - torch-version: 1.13.0 + cuda-version: 'cu113' + - torch-version: 1.13.0 + cuda-version: 'cu115' + - torch-version: 1.13.0 + cuda-version: 'cu118' + + - torch-version: 2.0.0 + python-version: '3.7' + - torch-version: 2.0.0 + cuda-version: 'cu102' + - torch-version: 2.0.0 + cuda-version: 'cu113' + - torch-version: 2.0.0 + cuda-version: 'cu115' + - torch-version: 2.0.0 + cuda-version: 'cu116' + + - os: windows-2019 + cuda-version: 'cu102' + - os: windows-2019 + torch-version: 1.13.0 + python-version: '3.11' + + # - os: windows-2019 + # torch-version: 1.13.0 + # cuda-version: 'cu117' + # python-version: '3.9' + + + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade pip + run: | + pip install --upgrade setuptools + pip install ninja + + - name: Free up disk space + if: ${{ runner.os == 'Linux' }} + run: | + sudo rm -rf /usr/share/dotnet + + - name: Install CUDA ${{ matrix.cuda-version }} + if: ${{ matrix.cuda-version != 'cpu' }} + run: | + bash .github/workflows/cuda/${{ runner.os }}.sh ${{ matrix.cuda-version }} + + - name: Install PyTorch ${{ matrix.torch-version }}+${{ matrix.cuda-version }} + run: | + pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/${{ matrix.cuda-version }} + python -c "import torch; print('PyTorch:', torch.__version__)" + python -c "import torch; print('CUDA:', torch.version.cuda)" + python -c "import torch; print('CUDA Available:', torch.cuda.is_available())" + + - name: Patch PyTorch static constexpr on Windows + if: ${{ runner.os == 'Windows' }} + run: | + Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` + sed -i '31,38c\ + TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + shell: bash + + - name: Set version + if: ${{ runner.os != 'macOS' }} + run: | + VERSION=`sed -n 's/^__version__ = "\(.*\)"/\1/p' gsplat/version.py` + TORCH_VERSION=`echo "pt${{ matrix.torch-version }}" | sed "s/..$//" | sed "s/\.//g"` + CUDA_VERSION=`echo ${{ matrix.cuda-version }}` + echo "New version name: $VERSION+$TORCH_VERSION$CUDA_VERSION" + sed -i "s/$VERSION/$VERSION+$TORCH_VERSION$CUDA_VERSION/" gsplat/version.py + shell: + bash + + - name: Install main package for CPU + if: ${{ matrix.cuda-version == 'cpu' }} + run: | + BUILD_NO_CUDA=1 pip install . + + - name: Build wheel + run: | + pip install wheel + source .github/workflows/cuda/${{ runner.os }}-env.sh ${{ matrix.cuda-version }} + python setup.py bdist_wheel --dist-dir=dist + shell: bash # `source` does not exist in windows powershell + + - name: Test wheel + run: | + cd dist + ls -lah + pip install *.whl + python -c "import gsplat; print('gsplat:', gsplat.__version__)" + cd .. + shell: bash # `ls -lah` does not exist in windows powershell \ No newline at end of file