Debian Codegraph @

.github/actions/build_conda/action.yml

raw
1 name: Conda build
2 description: Builds Faiss inside a Conda environment and uploads to repository when label is provided.
3 inputs:
4 label:
5 description: "The label to be used for uploads to Conda."
6 default: ""
7 required: false
8 cuda:
9 description: "CUDA toolkit version to use."
10 default: ""
11 required: false
12 cuvs:
13 description: "Enable cuVS support."
14 default: ""
15 required: false
16 runs:
17 using: composite
18 steps:
19 - name: Choose shell
20 shell: bash
21 id: choose_shell
22 run: |
23 # Use pwsh on Windows; bash everywhere else
24 if [ "${{ runner.os }}" != "Windows" ]; then
25 echo "shell=bash" >> "$GITHUB_OUTPUT"
26 else
27 echo "shell=pwsh" >> "$GITHUB_OUTPUT"
28 fi
29 - name: Setup miniconda
30 uses: conda-incubator/setup-miniconda@v3
31 with:
32 python-version: '3.11'
33 miniforge-version: latest # ensures conda-forge channel is used.
34 channels: conda-forge
35 conda-remove-defaults: 'true'
36 # Set to runner.arch=aarch64 if we're on arm64 because
37 # there's no miniforge ARM64 package, just aarch64.
38 # They are the same thing, just named differently.
39 # However there is an ARM64 for macOS, so exclude that.
40 architecture: ${{ (runner.arch == 'ARM64' && runner.os != 'macOS') && 'aarch64' || runner.arch }}
41 - name: Install conda build tools
42 shell: ${{ steps.choose_shell.outputs.shell }}
43 run: |
44 # Ensure starting packages are from conda-forge.
45 conda list --show-channel-urls
46 conda install -y -q "conda!=24.11.0,<=25.07"
47 conda install -y -q "conda-build=25.3.1" "liblief=0.14.1"
48 - name: Enable anaconda uploads
49 if: inputs.label != ''
50 shell: ${{ steps.choose_shell.outputs.shell }}
51 env:
52 PACKAGE_TYPE: ${{ inputs.label }}
53 run: |
54 conda list --show-channel-urls
55 conda install -y -q anaconda-client
56 conda config --set anaconda_upload yes
57 - name: Conda build (CPU)
58 if: inputs.label == '' && inputs.cuda == ''
59 shell: ${{ steps.choose_shell.outputs.shell }}
60 working-directory: conda
61 run: |
62 conda list --show-channel-urls
63 conda build faiss --python 3.11 -c pytorch
64 - name: Conda build (CPU) w/ anaconda upload
65 if: inputs.label != '' && inputs.cuda == ''
66 shell: ${{ steps.choose_shell.outputs.shell }}
67 working-directory: conda
68 env:
69 PACKAGE_TYPE: ${{ inputs.label }}
70 run: |
71 conda list --show-channel-urls
72 conda build faiss --user pytorch --label ${{ inputs.label }} -c pytorch
73 - name: Conda build (GPU)
74 if: inputs.label == '' && inputs.cuda != '' && inputs.cuvs == ''
75 shell: ${{ steps.choose_shell.outputs.shell }}
76 working-directory: conda
77 run: |
78 conda list --show-channel-urls
79 conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
80 -c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
81 - name: Conda build (GPU) w/ anaconda upload
82 if: inputs.label != '' && inputs.cuda != '' && inputs.cuvs == ''
83 shell: ${{ steps.choose_shell.outputs.shell }}
84 working-directory: conda
85 env:
86 PACKAGE_TYPE: ${{ inputs.label }}
87 run: |
88 conda list --show-channel-urls
89 conda build faiss-gpu --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
90 --user pytorch --label ${{ inputs.label }} -c pytorch -c nvidia/label/cuda-${{ inputs.cuda }} -c nvidia
91 - name: Conda build (GPU w/ cuVS)
92 if: inputs.label == '' && inputs.cuda != '' && inputs.cuvs != ''
93 shell: ${{ steps.choose_shell.outputs.shell }}
94 working-directory: conda
95 run: |
96 conda list --show-channel-urls
97 conda build faiss-gpu-cuvs --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
98 -c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia
99 - name: Conda build (GPU w/ cuVS) w/ anaconda upload
100 if: inputs.label != '' && inputs.cuda != '' && inputs.cuvs != ''
101 shell: ${{ steps.choose_shell.outputs.shell }}
102 working-directory: conda
103 env:
104 PACKAGE_TYPE: ${{ inputs.label }}
105 run: |
106 conda list --show-channel-urls
107 conda build faiss-gpu-cuvs --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
108 --user pytorch --label ${{ inputs.label }} -c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia
109 - name: Check installed packages channel
110 shell: ${{ steps.choose_shell.outputs.shell }}
111 run: |
112 # Shows that all installed packages are from conda-forge.
113 conda list --show-channel-urls