|
1 | 1 | name: stable_diffusion_1_5_cpp
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | pull_request:
|
4 | 5 | paths:
|
5 | 6 | - image_generation/stable_diffusion_1_5/cpp/**
|
6 | 7 | - image_generation/common/**
|
7 | 8 | - .github/workflows/stable_diffusion_1_5_cpp.yml
|
8 | 9 | - thirdparty/openvino_tokenizers
|
| 10 | + |
| 11 | +env: |
| 12 | + working_directory: "./image_generation/stable_diffusion_1_5/cpp/" |
| 13 | + |
9 | 14 | concurrency:
|
10 | 15 | group: ${{ github.workflow }}-${{ github.ref }}
|
11 | 16 | cancel-in-progress: true
|
| 17 | + |
12 | 18 | jobs:
|
13 | 19 | stable_diffusion_1_5_cpp-linux:
|
14 | 20 | runs-on: ubuntu-20.04-8-cores
|
| 21 | + defaults: |
| 22 | + run: |
| 23 | + # Do not ignore bash profile files. From: |
| 24 | + # https://github.com/marketplace/actions/setup-miniconda#important |
| 25 | + shell: bash -l {0} |
15 | 26 | steps:
|
16 | 27 | - uses: actions/checkout@v4
|
17 | 28 | with:
|
18 | 29 | submodules: recursive
|
19 |
| - - uses: actions/setup-python@v4 |
| 30 | + |
| 31 | + - name: Setup conda |
| 32 | + uses: conda-incubator/setup-miniconda@v3 |
20 | 33 | with:
|
21 |
| - python-version: 3.8 |
22 |
| - - name: Install OpenVINO |
| 34 | + miniconda-version: "latest" |
| 35 | + activate-environment: openvino_sd_cpp |
| 36 | + python-version: "3.10" |
| 37 | + |
| 38 | + - name: Install OpenVINO and other conda dependencies |
23 | 39 | run: |
|
24 |
| - set -e |
25 |
| - mkdir openvino |
26 |
| - curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.1.0-14645-e6dc0865128/l_openvino_toolkit_ubuntu20_2024.1.0.dev20240304_x86_64.tgz | tar --directory ./openvino/ --strip-components 1 -xz |
27 |
| - sudo ./openvino/install_dependencies/install_openvino_dependencies.sh |
28 |
| - - name: Download / convert models |
| 40 | + conda activate openvino_sd_cpp |
| 41 | + conda install -c conda-forge openvino c-compiler cxx-compiler make cmake |
| 42 | + conda env config vars set LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH |
| 43 | +
|
| 44 | + - name: Install python dependencies |
| 45 | + working-directory: ${{ env.working_directory }} |
29 | 46 | run: |
|
30 |
| - set -e |
31 |
| - source ./openvino/setupvars.sh |
32 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/scripts/ |
33 |
| - python -m pip install -U pip |
34 |
| - python -m pip install -r ./requirements.txt |
35 |
| - python -m pip install ../../../../thirdparty/openvino_tokenizers/ |
36 |
| - python convert_model.py -sd runwayml/stable-diffusion-v1-5 -b 1 -t FP16 -dyn True |
| 47 | + conda activate openvino_sd_cpp |
| 48 | + python -m pip install -r requirements.txt |
| 49 | + python -m pip install ../../../thirdparty/openvino_tokenizers/[transformers] |
| 50 | +
|
| 51 | + - name: Download and convert model and tokenizer |
| 52 | + working-directory: ${{ env.working_directory }} |
| 53 | + run: | |
| 54 | + conda activate openvino_sd_cpp |
| 55 | + export MODEL_PATH="models/stable_diffusion_v1_5_ov/FP16" |
| 56 | + optimum-cli export openvino --model runwayml/stable-diffusion-v1-5 --task stable-diffusion --convert-tokenizer --weight-format fp16 $MODEL_PATH |
| 57 | + convert_tokenizer $MODEL_PATH/tokenizer/ --tokenizer-output-type i32 -o $MODEL_PATH/tokenizer/ |
| 58 | +
|
37 | 59 | - name: Build app
|
| 60 | + working-directory: ${{ env.working_directory }} |
38 | 61 | run: |
|
39 |
| - set -e |
40 |
| - source ./openvino/setupvars.sh |
41 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/ |
| 62 | + conda activate openvino_sd_cpp |
42 | 63 | cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
|
43 | 64 | cmake --build ./build/ --config Release --parallel
|
| 65 | +
|
44 | 66 | - name: Run app
|
| 67 | + working-directory: ${{ env.working_directory }} |
45 | 68 | run: |
|
46 |
| - set -e |
47 |
| - source ./openvino/setupvars.sh |
48 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/build |
49 |
| - ./stable_diffusion -m ../scripts/runwayml/stable-diffusion-v1-5 -t FP16_dyn |
| 69 | + ./build/stable_diffusion -m ./models/stable_diffusion_v1_5_ov -t FP16 |
| 70 | +
|
50 | 71 | stable_diffusion_1_5_cpp-windows:
|
51 | 72 | runs-on: windows-latest
|
52 | 73 | steps:
|
53 | 74 | - uses: actions/checkout@v4
|
54 | 75 | with:
|
55 | 76 | submodules: recursive
|
56 |
| - - uses: actions/setup-python@v4 |
| 77 | + |
| 78 | + - name: Setup conda |
| 79 | + uses: conda-incubator/setup-miniconda@v3 |
57 | 80 | with:
|
58 |
| - python-version: 3.8 |
59 |
| - - name: Initialize OpenVINO |
60 |
| - shell: cmd |
| 81 | + miniconda-version: "latest" |
| 82 | + activate-environment: openvino_sd_cpp |
| 83 | + python-version: "3.10" |
| 84 | + |
| 85 | + - name: Install OpenVINO and other conda dependencies |
| 86 | + run: | |
| 87 | + conda activate openvino_sd_cpp |
| 88 | + conda install -c conda-forge openvino c-compiler cxx-compiler make cmake |
| 89 | + |
| 90 | + - name: Install python dependencies |
| 91 | + working-directory: ${{ env.working_directory }} |
61 | 92 | run: |
|
62 |
| - curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.1.0-14645-e6dc0865128/w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64.zip |
63 |
| - unzip ov.zip |
64 |
| - - name: Download / convert a model / tokenizer |
65 |
| - shell: cmd |
| 93 | + conda activate openvino_sd_cpp |
| 94 | + python -m pip install -r requirements.txt |
| 95 | + python -m pip install ../../../thirdparty/openvino_tokenizers/[transformers] |
| 96 | + |
| 97 | + - name: Download and convert model and tokenizer |
| 98 | + working-directory: ${{ env.working_directory }} |
66 | 99 | run: |
|
67 |
| - call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64/setupvars.bat |
68 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/scripts/ |
69 |
| - python -m pip install -r ./requirements.txt |
70 |
| - python -m pip install ../../../../thirdparty/openvino_tokenizers/ |
71 |
| - python convert_model.py -sd runwayml/stable-diffusion-v1-5 -b 1 -t FP16 -dyn True |
| 100 | + conda activate openvino_sd_cpp |
| 101 | + $env:MODEL_PATH='models/stable_diffusion_v1_5_ov/FP16' |
| 102 | + optimum-cli export openvino --model runwayml/stable-diffusion-v1-5 --task stable-diffusion --convert-tokenizer --weight-format fp16 $env:MODEL_PATH |
| 103 | + convert_tokenizer $env:MODEL_PATH/tokenizer/ --tokenizer-output-type i32 -o $env:MODEL_PATH/tokenizer/ |
| 104 | + |
72 | 105 | - name: Build app
|
73 |
| - shell: cmd |
| 106 | + working-directory: ${{ env.working_directory }} |
74 | 107 | run: |
|
75 |
| - call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64/setupvars.bat |
76 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/ |
| 108 | + conda activate openvino_sd_cpp |
77 | 109 | cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
|
78 | 110 | cmake --build ./build/ --config Release --parallel
|
| 111 | + |
79 | 112 | - name: Run app
|
80 |
| - shell: cmd |
| 113 | + working-directory: ${{ env.working_directory }} |
81 | 114 | run: |
|
82 |
| - call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64/setupvars.bat |
83 |
| - cd ./image_generation/stable_diffusion_1_5/cpp/build/ |
84 |
| - call "./Release/stable_diffusion.exe" -m ../scripts/runwayml/stable-diffusion-v1-5 -t FP16_dyn |
| 115 | + & "./build/Release/stable_diffusion.exe" -m ./models/stable_diffusion_v1_5_ov -t FP16 --dynamic |
0 commit comments