-
Notifications
You must be signed in to change notification settings - Fork 2
179 lines (167 loc) · 5.62 KB
/
precompiled_nif.yml
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
name: precompile
on:
push:
branches:
- pv-feat/precompile-artifacts
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
precompile_nif_macos:
runs-on: ${{ matrix.os }}
env:
MIX_ENV: prod
NX_IREE_PREFER_PRECOMPILED: false
NX_IREE_SOURCE_DIR: ./build-cache/iree
IREE_GIT_REV: candidate-20240604.914
strategy:
fail-fast: false
matrix:
nif_version: [2.16, 2.17]
os: [macos-12, macos-14]
arch: [x86_64, aarch64]
exclude:
- os: macos-12
arch: aarch64
- os: macos-14
arch: x86_64
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install asdf and tools
uses: asdf-vm/actions/install@v3
- name: Setup dependencies and env
run: |
brew install ninja
mix local.hex --force
mix local.rebar --force
echo "NX_IREE_SOURCE_DIR=$(elixir -e 'IO.puts(Path.absname(~s(${{env.NX_IREE_SOURCE_DIR}})))')" > $GITHUB_ENV
echo "PKG_NAME=libnx_iree-macos-${{matrix.arch}}-nif-${{matrix.nif_version}}" >> $GITHUB_ENV
- name: Cache mix dependencies
id: cache-mix-deps
uses: actions/cache@v4
with:
key: deps-${{ hashFiles('mix.lock') }}
path: |
./deps
- name: Get mix deps
if: steps.cache-mix-deps.outputs.cache-hit != 'true'
run: mix deps.get
- name: Cache IREE dir
id: cache-iree-dir
uses: actions/cache@v4
with:
key: iree-dir-${{ env.IREE_GIT_REV }}
path: |
${{ env.NX_IREE_SOURCE_DIR }}
- name: Clone IREE
if: steps.cache-iree-dir.outputs.cache-hit != 'true'
run: make clone_iree
- name: Compile NIF
run: |
mix compile
mkdir ${{ env.PKG_NAME }}
cp ./cache/libnx_iree.so ./${{ env.PKG_NAME }}/libnx_iree.so
cp -r ./cache/iree-runtime ./${{ env.PKG_NAME }}/iree-runtime
tar -czf ${{ env.PKG_NAME }}.tar.gz ${{ env.PKG_NAME }}
- name: Release Artifacts
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./*.tar.gz
precompile_nif_linux_x86_64:
runs-on: ubuntu-20.04
env:
MIX_ENV: prod
NX_IREE_PREFER_PRECOMPILED: false
NX_IREE_SOURCE_DIR: ./build-cache/iree
IREE_GIT_REV: candidate-20240604.914
ImageOS: ubuntu20
LANG: en_US.UTF-8
LANGUAGE: en_US:en
LC_ALL: en_US.UTF-8
DEBIAN_FRONTEND: noninteractive
strategy:
fail-fast: false
matrix:
nif_version: [2.16, 2.17]
include:
- container: "nvidia/cuda:12.5.0-devel-ubuntu20.04"
cuda_version: "12.5.0"
cuda_id: "12"
cudnn_id: "8"
cudnn_tarball: "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-9.2.0.82_cuda12-archive.tar.xz"
container: ${{ matrix.container }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install asdf and tools
uses: asdf-vm/actions/install@v3
- name: cuda-toolkit
uses: Jimver/[email protected]
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.0
- name: Setup dependencies and env
run: |
apt-get update
apt-get install -y build-essential automake autoconf pkg-config bc curl git libssl-dev gzip python3 ca-certificates \
locales curl wget cmake
echo "${LANG} UTF-8" >> /etc/locale.gen
locale-gen
update-locale LANG=${LANG}
mix local.hex --force
mix local.rebar --force
echo "NX_IREE_SOURCE_DIR=$(elixir -e 'IO.puts(Path.absname(~s(${{env.NX_IREE_SOURCE_DIR}})))')" > $GITHUB_ENV
echo "PKG_NAME=libnx_iree-linux-x86_64-nif-${{matrix.nif_version}}" >> $GITHUB_ENV
- name: Download and install cudnn
run: |
curl -fSL "${{ matrix.cudnn_tarball }}" -o cudnn.tar.xz
mkdir -p cudnn
tar -xvf cudnn.tar.xz -C cudnn --strip-components=1
rm -f cudnn.tar.xz
cp -a cudnn/include/* /usr/local/cuda/include/
if [ -d "$(pwd)/cudnn/lib" ]; then
cp -a cudnn/lib/* /usr/local/cuda/lib64/
fi
if [ -d "$(pwd)/cudnn/lib64" ]; then
cp -a cudnn/lib64/* /usr/local/cuda/lib64/
fi
rm -rf cudnn
- name: Cache mix dependencies
id: cache-mix-deps
uses: actions/cache@v4
with:
key: deps-${{ hashFiles('mix.lock') }}
path: |
./deps
- name: Get mix deps
if: steps.cache-mix-deps.outputs.cache-hit != 'true'
run: mix deps.get
- name: Cache IREE dir
id: cache-iree-dir
uses: actions/cache@v4
with:
key: iree-dir-${{ env.IREE_GIT_REV }}
path: |
${{ env.NX_IREE_SOURCE_DIR }}
- name: Clone IREE
if: steps.cache-iree-dir.outputs.cache-hit != 'true'
run: make clone_iree
- name: Compile NIF
run: |
mix compile
mkdir ${{ env.PKG_NAME }}
cp ./cache/libnx_iree.so ./${{ env.PKG_NAME }}/libnx_iree.so
cp -r ./cache/iree-runtime ./${{ env.PKG_NAME }}/iree-runtime
tar -czf ${{ env.PKG_NAME }}.tar.gz ${{ env.PKG_NAME }}
- name: Release Artifacts
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./*.tar.gz