File: publish-elastix.yml

package info (click to toggle)
elastix 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,644 kB
  • sloc: cpp: 85,720; lisp: 4,118; python: 1,045; sh: 200; xml: 182; makefile: 33
file content (182 lines) | stat: -rw-r--r-- 6,826 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: ElastixPublish

on:
  workflow_dispatch:

jobs:
  publish:
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 3
      matrix:
        os: [ubuntu-22.04, windows-2022, macos-14]
        include:
          - os: ubuntu-22.04
            libtorch-cpu-url: "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.8.0%2Bcpu.zip"
            libtorch-cuda-url: "https://download.pytorch.org/libtorch/cu128/libtorch-shared-with-deps-2.8.0%2Bcu128.zip"
            cuda_toolkit_version: '12.8.0'
            itk-git-tag: "v5.4.5"
            c-compiler: "gcc"
            cxx-compiler: "g++"
            cmake-build-type: "Release"
            libs:
              - elastix-build/bin/libelx-ANNlib.so
          - os: windows-2022
            libtorch-cpu-url: "https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.8.0%2Bcpu.zip"
            libtorch-cuda-url: "https://download.pytorch.org/libtorch/cu128/libtorch-win-shared-with-deps-2.8.0%2Bcu128.zip"
            cuda_toolkit_version: '12.8.0'
            itk-git-tag: "v5.4.5"
            c-compiler: "cl.exe"
            cxx-compiler: "cl.exe"
            cmake-build-type: "Release"
            libs:
              - elastix-build/bin/elx-ANNlib.dll
            vcvars64: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
          - os: macos-14
            c-compiler: "clang"
            cxx-compiler: "clang++"
            libtorch-cpu-url: "https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.8.0.zip"
            itk-git-tag: "v5.4.5"
            cmake-build-type: "Release"
            libs:
              - elastix-build/bin/libelx-ANNlib.dylib
    steps:
      - name: Free disk space
        if: matrix.os != 'windows-2022'
        run: |
          echo "Disk before cleanup:"
          df -h
          sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
          sudo docker system prune -af || true
          sudo rm -rf /var/lib/apt/lists/*
          echo "Disk after cleanup:"
          df -h
        shell: bash

      - name: Clone elastix
        uses: actions/checkout@v3

      - name: Make directory structure
        run: |
          items=(*)
          mkdir elastix-source
          mv ${items[*]} elastix-source
          mv .editorconfig elastix-source
          mv .clang-format elastix-source
          mv elastix-source/Dockerfile .
        shell: bash

      - name: Get specific version of CMake, Ninja
        uses: lukka/get-cmake@latest

      - name: Clone and build ITK
        uses: ./.github/actions/build_itk
        with:
          itk-git-tag: ${{ matrix.itk-git-tag }}
          c-compiler: ${{ matrix.c-compiler }}
          cxx-compiler: ${{ matrix.cxx-compiler }}
          cmake-build-type: ${{ matrix.cmake-build-type }}
          vcvars: ${{ matrix.vcvars64 }}

      - name: Download and extract libtorch cpu (non-MacOS)
        if: matrix.os != 'macos-14'
        uses: ./.github/actions/download_libtorch
        with:
          libtorch_url: ${{ matrix.libtorch-cpu-url }}

      - name: Build libtorch cpu (MacOS)
        if: matrix.os == 'macos-14'
        uses: ./.github/actions/build_libtorch
        with:
          install_prefix: ${{ github.workspace }}/libtorch/libtorch

      - name: Configure/Build elastix with IMPACT libtorch cpu
        uses: ./.github/actions/build_elastix
        with:
          c-compiler: ${{ matrix.c-compiler }}
          cxx-compiler: ${{ matrix.cxx-compiler }}
          cmake-build-type: ${{ matrix.cmake-build-type }}
          vcvars: ${{ matrix.vcvars64 }}

      - name: Cleanup libtorch (CPU) (Linux)
        if: matrix.os == 'ubuntu-22.04'
        run: |
          mv elastix-build/bin/libImpactMetric.so elastix-build/bin/libImpactMetricCpu.so
          rm -rf libtorch
        shell: bash

      - name: Cleanup libtorch (CPU) [Windows]
        if: matrix.os == 'windows-2022'
        run: |
          mv elastix-build/bin/ImpactMetric.dll elastix-build/bin/ImpactMetricCpu.dll
          rmdir /S /Q libtorch
        shell: cmd

      - name: Install CUDA Toolkit (Windows)
        if: matrix.os == 'windows-2022'
        uses: Jimver/cuda-toolkit@v0.2.29
        with:
          cuda: 11.8.0
          use-github-cache: false
          use-local-cache: false

      - name: Install CUDA Toolkit (Linux)
        if: matrix.os == 'ubuntu-22.04'
        uses: Jimver/cuda-toolkit@v0.2.23
        with:
          cuda: 12.8.0
          sub-packages: '["toolkit"]'
          method: 'network'

      - name: Download and extract libtorch cuda
        if: matrix.os != 'macos-14'
        uses: ./.github/actions/download_libtorch
        with:
          libtorch_url: ${{ matrix.libtorch-cuda-url }}

      - name: Build elastix with Impact Cuda (Windows)
        if: matrix.os == 'windows-2022'
        shell: cmd
        run: |
          cd elastix-build
          cmake -DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" ^
              -DCMAKE_CXX_COMPILER="${{ inputs.cxx-compiler }}" ^
              -DCMAKE_BUILD_TYPE="${{ inputs.cmake-build-type }}" ^
              -DITK_DIR=../ITK-build ^
              -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler -Xcompiler \"/D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH\"" ^
              -DTorch_DIR=../libtorch/libtorch/share/cmake/Torch ^
              -DUSE_ALL_COMPONENTS=ON ^
              -DBUILD_TESTING:BOOL=ON ^
              -DELASTIX_USE_GTEST=ON ^
              -GNinja ../elastix-source
          cmake --build . --target ImpactMetric
          mv bin/ImpactMetric.dll bin/ImpactMetricCuda.dll
          mv bin/ImpactMetricCpu.dll bin/ImpactMetric.dll


      - name: Build elastix with Impact Cuda (Linux)
        if: matrix.os == 'ubuntu-22.04'
        shell: bash
        run: |
          cd elastix-build
          cmake -DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" \
              -DCMAKE_CXX_COMPILER="${{ inputs.cxx-compiler }}" \
              -DCMAKE_BUILD_TYPE="${{ inputs.cmake-build-type }}" \
              -DITK_DIR=../ITK-build \
              -DTorch_DIR=../libtorch/libtorch/share/cmake/Torch \
              -DUSE_ALL_COMPONENTS=ON \
              -DBUILD_TESTING:BOOL=ON \
              -DELASTIX_USE_GTEST=ON \
              -GNinja ../elastix-source
          cmake --build . --target ImpactMetric
          mv bin/libImpactMetric.so bin/libImpactMetricCuda.so
          mv bin/libImpactMetricCpu.so bin/libImpactMetric.so


      - name: Publish
        uses: ./.github/actions/publish
        with:
          libs: ${{ join(matrix.libs, ' ') }} elastix-build/bin/*ImpactMetric*
          upload-name: ${{ matrix.os }}-libtorch-2.8.0
          docker-username: ${{ secrets.DOCKER_HUB_USERNAME }}
          docker-password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}