From 60300eb50a6b5839727e230e4363cdb83c14e129 Mon Sep 17 00:00:00 2001 From: Mat Sz Date: Sun, 21 Apr 2024 20:20:33 +0200 Subject: [PATCH] first commit --- .github/workflows/build.yml | 263 ++++++++++++++++++++++++++++++++++++ .prettierrc.json | 6 + requirements.cpu.txt | 4 + requirements.cuda.txt | 5 + requirements.directml.txt | 3 + requirements.rocm.txt | 4 + requirements.txt | 14 ++ 7 files changed, 299 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .prettierrc.json create mode 100644 requirements.cpu.txt create mode 100644 requirements.cuda.txt create mode 100644 requirements.directml.txt create mode 100644 requirements.rocm.txt create mode 100644 requirements.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c6d95ff --- /dev/null +++ b/.github/workflows/build.yml @@ -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.*' diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..d9191c9 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "tabWidth": 2, + "singleQuote": true, + "semi": true, + "arrowParens": "avoid" +} diff --git a/requirements.cpu.txt b/requirements.cpu.txt new file mode 100644 index 0000000..d775cc7 --- /dev/null +++ b/requirements.cpu.txt @@ -0,0 +1,4 @@ +--extra-index-url https://download.pytorch.org/whl/nightly/cpu +-r requirements.txt +torch +onnxruntime \ No newline at end of file diff --git a/requirements.cuda.txt b/requirements.cuda.txt new file mode 100644 index 0000000..1dcc51c --- /dev/null +++ b/requirements.cuda.txt @@ -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 \ No newline at end of file diff --git a/requirements.directml.txt b/requirements.directml.txt new file mode 100644 index 0000000..97cc5ca --- /dev/null +++ b/requirements.directml.txt @@ -0,0 +1,3 @@ +-r requirements.txt +torch-directml +onnxruntime-directml \ No newline at end of file diff --git a/requirements.rocm.txt b/requirements.rocm.txt new file mode 100644 index 0000000..de7c9a9 --- /dev/null +++ b/requirements.rocm.txt @@ -0,0 +1,4 @@ +--extra-index-url https://download.pytorch.org/whl/nightly/rocm6.0 +-r requirements.txt +torch +onnxruntime diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8c4e018 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,14 @@ +torchvision +torchsde +einops +safetensors +accelerate +pyyaml +Pillow +scipy +tqdm +psutil +transformers +diffusers[torch] +voluptuous +onnx \ No newline at end of file