Speed up tests (#1028) #7
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
name: stable_diffusion_1_5_cpp | |
on: | |
workflow_dispatch: | |
pull_request: | |
merge_group: | |
push: | |
branches: | |
- master | |
- 'releases/**' | |
permissions: read-all # Required by https://github.com/ossf/scorecard/blob/e23b8ad91fd6a64a0a971ca4fc0a4d1650725615/docs/checks.md#token-permissions | |
env: | |
PYTHON_VERSION: '3.10' | |
LINUX_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-17053-939b35a9629/l_openvino_toolkit_ubuntu20_2024.5.0.dev20241018_x86_64.tgz | |
WINDOWS_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-17053-939b35a9629/w_openvino_toolkit_windows_2024.5.0.dev20241018_x86_64.zip | |
OV_INSTALL_DIR: ${{ github.workspace }}/ov | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
stable_diffusion_1_5_cpp-linux: | |
runs-on: ubuntu-20.04-8-cores | |
defaults: | |
run: | |
shell: bash -l {0} | |
env: | |
build_dir: ${{ github.workspace }}//build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download OpenVINO archive | |
run: | | |
wget ${{ env.LINUX_OV_ARCHIVE_URL}} --progress=bar:force:noscroll -O openvino_package.tar.gz | |
mkdir ${{ env.OV_INSTALL_DIR }} | |
tar -xzf openvino_package.tar.gz -C ${{ env.OV_INSTALL_DIR }} --strip-components=1 | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: 'pip' | |
- name: Build app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ${{ env.build_dir }} | |
cmake --build ${{ env.build_dir }} --config Release --target stable_diffusion lora_stable_diffusion py_generate_pipeline --parallel | |
- name: Create virtual environment | |
run: python3 -m venv openvino_sd_cpp | |
- name: Install python dependencies | |
run: | | |
source openvino_sd_cpp/bin/activate | |
python -m pip install ./thirdparty/openvino_tokenizers/[transformers] --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly | |
python -m pip install -r ./samples/requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly | |
- name: Download and convert models and tokenizer | |
run: | | |
source openvino_sd_cpp/bin/activate | |
optimum-cli export openvino --model dreamlike-art/dreamlike-anime-1.0 --weight-format fp16 --task stable-diffusion models/dreamlike-art-dreamlike-anime-1.0/FP16 | |
wget -O ./models/soulcard.safetensors https://civitai.com/api/download/models/72591 | |
- name: Run main app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
${{ env.build_dir }}/samples/cpp/text2image/stable_diffusion ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
- name: Run LoRA app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
${{ env.build_dir }}/samples/cpp/text2image/lora_stable_diffusion ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "curly-haired unicorn in the forest, anime, line" ./models/soulcard.safetensors 0.7 | |
- name: Run Python main app | |
run: | | |
source openvino_sd_cpp/bin/activate | |
source ./ov/setupvars.sh | |
python ./samples/python/text2image/main.py ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
LD_LIBRARY_PATH: ${{ env.build_dir }}/openvino_genai | |
- name: Run Python LoRA app | |
run: | | |
source openvino_sd_cpp/bin/activate | |
source ./ov/setupvars.sh | |
python ./samples/python/text2image/lora.py ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "curly-haired unicorn in the forest, anime, line" ./models/soulcard.safetensors 0.7 | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
LD_LIBRARY_PATH: ${{ env.build_dir }}/openvino_genai | |
stable_diffusion_1_5_cpp-windows: | |
runs-on: windows-2019 | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
build_dir: ${{ github.workspace }}\build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download OpenVINO archive | |
run: | | |
mkdir ${{ env.OV_INSTALL_DIR }} | |
pushd ${{ env.OV_INSTALL_DIR }} | |
Invoke-WebRequest "${{ env.WINDOWS_OV_ARCHIVE_URL}}" -OutFile "openvino_package.zip" | |
Expand-Archive openvino_package.zip -DestinationPath ./tmp | |
mv ./tmp/*/* . | |
popd | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: 'pip' | |
- name: Build app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ${{ env.build_dir }} | |
cmake --build ${{ env.build_dir }} --config Release --target stable_diffusion lora_stable_diffusion py_generate_pipeline --parallel | |
- name: Create virtual environment | |
run: python -m venv openvino_sd_cpp | |
- name: Install python dependencies | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
python -m pip install ./thirdparty/openvino_tokenizers/[transformers] --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly | |
python -m pip install -r ./samples/requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly | |
- name: Download and convert models and tokenizer | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
optimum-cli export openvino --model dreamlike-art/dreamlike-anime-1.0 --task stable-diffusion --weight-format fp16 models/dreamlike-art-dreamlike-anime-1.0/FP16 | |
Invoke-WebRequest -Uri 'https://civitai.com/api/download/models/72591' -OutFile 'models/soulcard.safetensors' | |
- name: Run main app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
"${{ env.build_dir }}/samples/cpp/text2image/Release/stable_diffusion.exe ./models/dreamlike-art-dreamlike-anime-1.0/FP16 'cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting'" | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
- name: Run LoRA app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
"${{ env.build_dir }}/samples/cpp/text2image/Release/lora_stable_diffusion.exe ./models/dreamlike-art-dreamlike-anime-1.0/FP16 'curly-haired unicorn in the forest, anime, line' ./models/soulcard.safetensors 0.7" | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
- name: Run Python main app | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
python .\samples\python\text2image\main.py .\models\dreamlike-art-dreamlike-anime-1.0\FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
PYTHONPATH: ${{ env.build_dir }} | |
- name: Run Python LoRA app | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
python .\samples\python\text2image\lora.py .\models\dreamlike-art-dreamlike-anime-1.0\FP16 "curly-haired unicorn in the forest, anime, line" .\models\soulcard.safetensors 0.7 | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
PYTHONPATH: ${{ env.build_dir }} | |
Overall_Status: | |
name: ci/gha_overall_status_stable_diffusion | |
needs: [stable_diffusion_1_5_cpp-linux, stable_diffusion_1_5_cpp-windows] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check status of all jobs | |
if: >- | |
${{ | |
contains(needs.*.result, 'failure') || | |
contains(needs.*.result, 'cancelled') | |
}} | |
run: exit 1 |