forked from facebookresearch/faiss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
440 lines (434 loc) · 14.3 KB
/
config.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
version: 2.1
executors:
linux-x86_64-cpu:
docker:
- image: continuumio/miniconda3
resource_class: large
linux-x86_64-gpu:
environment:
CONDA_ARCH: Linux-x86_64
machine:
image: linux-cuda-11:2023.02.1
resource_class: gpu.nvidia.medium
linux-arm64-cpu:
environment:
CONDA_ARCH: Linux-aarch64
machine:
image: ubuntu-2004:current
resource_class: arm.medium
macosx-arm64-cpu:
environment:
CONDA_ARCH: MacOSX-arm64
macos:
xcode: 14.2.0 # minimum supported for M1
resource_class: macos.m1.large.gen1
windows-x86_64-cpu:
machine:
image: windows-server-2019-vs2019:stable
shell: bash.exe
resource_class: windows.medium
jobs:
format:
docker:
- image: ubuntu:22.04
steps:
- checkout
- run:
name: Install clang-format
command: |
apt-get update
apt-get install -y git-core clang-format-11
- run:
name: Verify clang-format
command: |
git ls-files | grep -E '\.(cpp|h|cu|cuh)$' | xargs clang-format-11 -i
if git diff --quiet; then
echo "Formatting OK!"
else
echo "Formatting not OK!"
echo "------------------"
git --no-pager diff --color
exit 1
fi
build_conda:
parameters:
label:
type: string
default: ""
cuda:
type: string
default: ""
raft:
type: string
default: ""
cuda_archs:
type: string
default: ""
compiler_version:
type: string
default: ""
exec:
type: executor
executor: << parameters.exec >>
environment:
OMP_NUM_THREADS: 10
PACKAGE_TYPE: <<parameters.label>>
CUDA_ARCHS: <<parameters.cuda_archs>>
steps:
- checkout
- run:
name: Install conda
command: |
if [ -n "${CONDA_ARCH}" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-${CONDA_ARCH}.sh --output miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
~/miniconda/bin/conda init
fi
- run:
name: Install conda build tools
command: |
conda config --set solver libmamba
# conda config --set verbosity 3
conda update -y -q conda
conda install -y -q conda-build
- when:
condition: << parameters.label >>
steps:
- run:
name: Enable anaconda uploads
command: |
conda install -y -q anaconda-client
conda config --set anaconda_upload yes
- when:
condition:
and:
- not: << parameters.label >>
- not: << parameters.cuda >>
steps:
- run:
name: Conda build (CPU)
no_output_timeout: 30m
command: |
cd conda
conda build faiss --python 3.11 -c pytorch
- when:
condition:
and:
- << parameters.label >>
- not: << parameters.cuda >>
steps:
- run:
name: Conda build (CPU) w/ anaconda upload
no_output_timeout: 30m
command: |
cd conda
conda build faiss --user pytorch --label <<parameters.label>> -c pytorch
- when:
condition:
and:
- not: << parameters.label >>
- << parameters.cuda >>
- not: << parameters.raft >>
steps:
- run:
name: Conda build (GPU)
no_output_timeout: 60m
command: |
sudo update-alternatives --set cuda /usr/local/cuda-<<parameters.cuda>>
cd conda
conda build faiss-gpu --variants '{ "cudatoolkit": "<<parameters.cuda>>", "c_compiler_version": "<<parameters.compiler_version>>", "cxx_compiler_version": "<<parameters.compiler_version>>" }' \
-c pytorch -c nvidia
- when:
condition:
and:
- << parameters.label >>
- << parameters.cuda >>
- not: << parameters.raft >>
steps:
- run:
name: Conda build (GPU) w/ anaconda upload
no_output_timeout: 60m
command: |
sudo update-alternatives --set cuda /usr/local/cuda-<<parameters.cuda>>
cd conda
conda build faiss-gpu --variants '{ "cudatoolkit": "<<parameters.cuda>>", "c_compiler_version": "<<parameters.compiler_version>>", "cxx_compiler_version": "<<parameters.compiler_version>>" }' \
--user pytorch --label <<parameters.label>> -c pytorch -c nvidia
- when:
condition:
and:
- not: << parameters.label >>
- << parameters.cuda >>
- << parameters.raft >>
steps:
- run:
name: Conda build (GPU w/ RAFT)
no_output_timeout: 60m
command: |
sudo update-alternatives --set cuda /usr/local/cuda-<<parameters.cuda>>
cd conda
conda build faiss-gpu-raft --variants '{ "cudatoolkit": "<<parameters.cuda>>", "c_compiler_version": "<<parameters.compiler_version>>", "cxx_compiler_version": "<<parameters.compiler_version>>" }' \
-c pytorch -c nvidia -c rapidsai -c conda-forge
- when:
condition:
and:
- << parameters.label >>
- << parameters.cuda >>
- << parameters.raft >>
steps:
- run:
name: Conda build (GPU w/ RAFT) w/ anaconda upload
no_output_timeout: 60m
command: |
sudo update-alternatives --set cuda /usr/local/cuda-<<parameters.cuda>>
cd conda
conda build faiss-gpu-raft --variants '{ "cudatoolkit": "<<parameters.cuda>>", "c_compiler_version": "<<parameters.compiler_version>>", "cxx_compiler_version": "<<parameters.compiler_version>>" }' \
--user pytorch --label <<parameters.label>> -c pytorch -c nvidia -c rapidsai -c conda-forge
build_cmake:
parameters:
exec:
type: executor
opt_level:
type: string
default: generic
gpu:
type: string
default: "OFF"
raft:
type: string
default: "OFF"
executor: << parameters.exec >>
environment:
OMP_NUM_THREADS: 10
MKL_THREADING_LAYER: GNU
steps:
- checkout
- run:
name: Install conda
command: |
if [ -n "${CONDA_ARCH}" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-${CONDA_ARCH}.sh --output miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
~/miniconda/bin/conda init
fi
- when:
condition:
equal: [ "ON", << parameters.gpu >> ]
steps:
- run:
name: Configure CUDA
command: sudo update-alternatives --set cuda /usr/local/cuda-11.4
- run:
name: Set up environment
command: |
conda config --set solver libmamba
conda update -y -q conda
conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64
- when:
condition:
equal: [ "ON", << parameters.raft >> ]
steps:
- run:
name: Install libraft
command: |
conda install -y -q libraft cudatoolkit=11.4 -c rapidsai-nightly -c nvidia -c pkgs/main -c conda-forge
- run:
name: Build all targets
no_output_timeout: 30m
command: |
eval "$(conda shell.bash hook)"
conda activate
cmake -B build \
-DBUILD_TESTING=ON \
-DBUILD_SHARED_LIBS=OFF \
-DFAISS_ENABLE_GPU=<< parameters.gpu >> \
-DFAISS_ENABLE_RAFT=<< parameters.raft >> \
-DFAISS_OPT_LEVEL=<< parameters.opt_level >> \
-DFAISS_ENABLE_C_API=ON \
-DPYTHON_EXECUTABLE=$(which python) \
-DCMAKE_BUILD_TYPE=Release \
-DBLA_VENDOR=Intel10_64_dyn \
-DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \
.
make -k -C build -j$(nproc)
- run:
name: C++ tests
command: |
export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/"
make -C build test
- run:
name: Install Python extension
command: |
cd build/faiss/python
python setup.py install
- when:
condition:
equal: [ "OFF", << parameters.gpu >> ]
steps:
- run:
name: Python tests (CPU only)
command: |
conda install -y -q pytorch -c pytorch
pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
pytest --junitxml=test-results/pytest/results-torch.xml tests/torch_*.py
- when:
condition:
equal: [ "ON", << parameters.gpu >> ]
steps:
- run:
name: Python tests (CPU + GPU)
command: |
conda install -y -q pytorch pytorch-cuda -c pytorch -c nvidia
pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
pytest --junitxml=test-results/pytest/results-torch.xml tests/torch_*.py
cp tests/common_faiss_tests.py faiss/gpu/test
pytest --junitxml=test-results/pytest/results-gpu.xml faiss/gpu/test/test_*.py
pytest --junitxml=test-results/pytest/results-gpu-torch.xml faiss/gpu/test/torch_*.py
- when:
condition:
equal: [ "avx2", << parameters.opt_level >> ]
steps:
- run:
name: Test avx2 loading
command: |
FAISS_DISABLE_CPU_FEATURES=AVX2 LD_DEBUG=libs python -c "import faiss" 2>&1 | grep faiss.so
LD_DEBUG=libs python -c "import faiss" 2>&1 | grep faiss_avx2.so
- store_test_results:
path: test-results
workflows:
version: 2
build:
jobs:
- format:
name: Format
- build_cmake:
name: Linux x86_64 (cmake)
exec: linux-x86_64-cpu
- build_cmake:
name: Linux x86_64 AVX2 (cmake)
exec: linux-x86_64-cpu
opt_level: "avx2"
- build_cmake:
name: Linux x86_64 GPU (cmake)
exec: linux-x86_64-gpu
gpu: "ON"
requires:
- Linux x86_64 AVX2 (cmake)
- build_cmake:
name: Linux x86_64 GPU w/ RAFT (cmake)
exec: linux-x86_64-gpu
gpu: "ON"
raft: "ON"
requires:
- Linux x86_64 GPU (cmake)
- build_conda:
name: Linux x86_64 (conda)
exec: linux-x86_64-cpu
- build_conda:
name: Windows x86_64 (conda)
exec: windows-x86_64-cpu
- build_conda:
name: Linux arm64 (conda)
exec: linux-arm64-cpu
- build_conda:
name: Linux x86_64 packages
exec: linux-x86_64-cpu
label: main
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_conda:
name: Linux x86_64 GPU packages (CUDA 11.4)
exec: linux-x86_64-gpu
label: main
cuda: "11.4"
cuda_archs: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
compiler_version: "11.2"
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_conda:
name: Linux x86_64 GPU w/ RAFT packages (CUDA 11.4)
exec: linux-x86_64-gpu
label: main
raft: "ON"
cuda: "11.4"
cuda_archs: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
compiler_version: "11.2"
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_conda:
name: Windows x86_64 packages
exec: windows-x86_64-cpu
label: main
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_conda:
name: OSX arm64 packages
exec: macosx-arm64-cpu
label: main
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_conda:
name: Linux arm64 packages
exec: linux-arm64-cpu
label: main
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- build_conda:
name: Linux x86_64 nightlies
exec: linux-x86_64-cpu
label: nightly
- build_conda:
name: Linux x86_64 GPU nightlies (CUDA 11.4)
exec: linux-x86_64-gpu
cuda: "11.4"
cuda_archs: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
compiler_version: "11.2"
label: nightly
- build_conda:
name: Linux x86_64 GPU w/ RAFT nightlies (CUDA 11.4)
exec: linux-x86_64-gpu
raft: "ON"
cuda: "11.4"
cuda_archs: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
compiler_version: "11.2"
label: nightly
- build_conda:
name: Windows x86_64 nightlies
exec: windows-x86_64-cpu
label: nightly
- build_conda:
name: OSX arm64 nightlies
exec: macosx-arm64-cpu
label: nightly
- build_conda:
name: Linux arm64 nightlies
exec: linux-arm64-cpu
label: nightly