Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-sz committed Apr 21, 2024
0 parents commit 60300eb
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 0 deletions.
263 changes: 263 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
name: Build

on:
push:
tags:
- '*'

jobs:
build-linux:
strategy:
fail-fast: false
matrix:
build:
- arch: 'x64'
type: 'cuda'
- arch: 'x64'
type: 'cpu'
- arch: 'x64'
type: 'rocm'
runs-on: ubuntu-latest
env:
artifact_name: linux-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.zst
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz'
uv_url: 'https://github.com/astral-sh/uv/releases/download/0.1.35/uv-x86_64-unknown-linux-gnu.tar.gz'
requirements: requirements.${{ matrix.build.type }}.txt
steps:
- uses: actions/checkout@v4

- name: Cache UV Download
uses: actions/cache@v4
id: cache-uv
with:
path: uv
key: ${{ runner.os }}-uv

- name: Download UV
if: steps.cache-uv.outputs.cache-hit != 'true'
run: curl -L -o uv.tar.gz ${{ env.uv_url }} && tar --strip-components=1 -xzf uv.tar.gz && rm uv.tar.gz

- name: Cache Python Download
id: cache-python
uses: actions/cache@v4
with:
path: python.tar.gz
key: ${{ runner.os }}-python

- name: Download Python
if: steps.cache-python.outputs.cache-hit != 'true'
run: curl -L -o python.tar.gz ${{ env.python_url }}

- name: Cache UV Packages
uses: actions/cache@v4
id: cache-uv-packages
with:
path: ~/.cache/uv
key: ${{ runner.os }}-${{ matrix.build.type }}-packages

- name: Extract Python
run: tar -xzf python.tar.gz

- name: Install packages
run: ./uv pip install -r ${{ env.requirements }} --python ./python/bin/python

- name: Build artifact
run: tar -I"zstd -9 -T0" -cf /tmp/${{ env.artifact_name }} python

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: /tmp/${{ env.artifact_name }}
compression-level: 0

build-windows:
strategy:
fail-fast: false
matrix:
build:
- arch: 'x64'
type: 'cuda'
- arch: 'x64'
type: 'directml'
- arch: 'x64'
type: 'cpu'
runs-on: windows-latest
env:
artifact_name: win32-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.zst
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-x86_64-pc-windows-msvc-install_only.tar.gz'
uv_url: 'https://github.com/astral-sh/uv/releases/download/0.1.35/uv-x86_64-pc-windows-msvc.zip'
requirements: requirements.${{ matrix.build.type }}.txt
steps:
- uses: actions/checkout@v4

- name: Cache UV Download
uses: actions/cache@v4
id: cache-uv
with:
path: uv.exe
key: ${{ runner.os }}-uv

- name: Download UV
if: steps.cache-uv.outputs.cache-hit != 'true'
run: curl -L -o uv.zip ${{ env.uv_url }} && unzip uv.zip -d . && rm uv.zip

- name: Cache Python Download
id: cache-python
uses: actions/cache@v4
with:
path: python.tar.gz
key: ${{ runner.os }}-python

- name: Download Python
if: steps.cache-python.outputs.cache-hit != 'true'
run: curl -L -o python.tar.gz ${{ env.python_url }}

- name: Cache UV Packages
uses: actions/cache@v4
id: cache-uv-packages
with:
path: ~\AppData\Local\uv\cache
key: ${{ runner.os }}-${{ matrix.build.type }}-packages

- name: Extract Python
run: tar -xzf python.tar.gz

- name: Install packages
run: .\uv.exe pip install -r ${{ env.requirements }} --python .\python\python.exe

- name: Build artifact
run: cd python && tar -cf - * | zstd -9 -T0 > C:\WINDOWS\Temp\${{ env.artifact_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: C:\WINDOWS\Temp\${{ env.artifact_name }}
compression-level: 0

build-mac-arm:
strategy:
fail-fast: false
matrix:
build:
- arch: 'arm64'
type: 'cpu'
runs-on: macos-14
env:
artifact_name: darwin-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.zst
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-aarch64-apple-darwin-install_only.tar.gz'
requirements: requirements.${{ matrix.build.type }}.txt
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: brew update && brew install uv

- name: Cache Python Download
id: cache-python
uses: actions/cache@v4
with:
path: python.tar.gz
key: ${{ runner.os }}-python

- name: Download Python
if: steps.cache-python.outputs.cache-hit != 'true'
run: curl -L -o python.tar.gz ${{ env.python_url }}

- name: Cache UV Packages
uses: actions/cache@v4
id: cache-uv-packages
with:
path: ~/.cache/uv
key: ${{ runner.os }}-${{ matrix.build.type }}-packages

- name: Extract Python
run: tar -xzf python.tar.gz

- name: Install packages
run: uv pip install -r ${{ env.requirements }} --python ./python/bin/python

- name: Build artifact
run: cd python && tar -cf - * | zstd -9 -T0 > /tmp/${{ env.artifact_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: /tmp/${{ env.artifact_name }}
compression-level: 0

build-mac-x86:
strategy:
fail-fast: false
matrix:
build:
- arch: 'x64'
type: 'cpu'
runs-on: macos-13
env:
artifact_name: darwin-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.zst
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-x86_64-apple-darwin-install_only.tar.gz'
requirements: requirements.${{ matrix.build.type }}.txt
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: brew update && brew install uv

- name: Cache Python Download
id: cache-python
uses: actions/cache@v4
with:
path: python.tar.gz
key: ${{ runner.os }}-python

- name: Download Python
if: steps.cache-python.outputs.cache-hit != 'true'
run: curl -L -o python.tar.gz ${{ env.python_url }}

- name: Cache UV Packages
uses: actions/cache@v4
id: cache-uv-packages
with:
path: ~/.cache/uv
key: ${{ runner.os }}-${{ matrix.build.type }}-packages

- name: Extract Python
run: tar -xzf python.tar.gz

- name: Install packages
run: uv pip install -r ${{ env.requirements }} --python ./python/bin/python

- name: Build artifact
run: cd python && tar -cf - * | zstd -9 -T0 > /tmp/${{ env.artifact_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: /tmp/${{ env.artifact_name }}
compression-level: 0

release:
runs-on: ubuntu-latest
permissions:
contents: write

needs:
- build-linux
- build-windows
- build-mac-arm
- build-mac-x86

steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true

- run: 'for filename in ./*.zst; do split -d -b 2000000000 "$filename" "$filename."; rm "$filename"; done'

- uses: ncipollo/release-action@v1
with:
artifacts: '*.zst.*'
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 2,
"singleQuote": true,
"semi": true,
"arrowParens": "avoid"
}
4 changes: 4 additions & 0 deletions requirements.cpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--extra-index-url https://download.pytorch.org/whl/nightly/cpu
-r requirements.txt
torch
onnxruntime
5 changes: 5 additions & 0 deletions requirements.cuda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--extra-index-url https://download.pytorch.org/whl/cu121
--extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/
-r requirements.txt
torch
onnxruntime-gpu
3 changes: 3 additions & 0 deletions requirements.directml.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
torch-directml
onnxruntime-directml
4 changes: 4 additions & 0 deletions requirements.rocm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--extra-index-url https://download.pytorch.org/whl/nightly/rocm6.0
-r requirements.txt
torch
onnxruntime
14 changes: 14 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
torchvision
torchsde
einops
safetensors
accelerate
pyyaml
Pillow
scipy
tqdm
psutil
transformers
diffusers[torch]
voluptuous
onnx

0 comments on commit 60300eb

Please sign in to comment.