@@ -12,6 +12,10 @@ inputs:
1212 description : ' Enable RAFT support.'
1313 required : false
1414 default : OFF
15+ rocm :
16+ description : ' Enable ROCm support.'
17+ required : false
18+ default : OFF
1519runs :
1620 using : composite
1721 steps :
3842 # install base packages for X86_64
3943 if [ "${{ runner.arch }}" = "X64" ]; then
4044 # TODO: unpin versions for gxx_linux-64 and sysroot_linux-64 and merge it with ARM64 below
41- conda install -y -q -c conda-forge gxx_linux-64=11.2 sysroot_linux-64=2.28
45+ if [ "${{ inputs.rocm }}" = "ON" ]; then
46+ conda install -y -q -c conda-forge gxx_linux-64 sysroot_linux-64
47+ else
48+ conda install -y -q -c conda-forge gxx_linux-64=11.2 sysroot_linux-64=2.28
49+ fi
4250 conda install -y -q mkl=2023 mkl-devel=2023
4351 fi
4452
6068 else
6169 conda install -y -q pytorch -c pytorch
6270 fi
71+ - name : ROCm - Install dependencies
72+ if : inputs.rocm == 'ON'
73+ shell : bash
74+ run : |
75+ # Update repos and install kmod, wget
76+ sudo apt-get update
77+ sudo apt-get install -y kmod wget
78+
79+ # Get UBUNTU version name
80+ UBUNTU_VERSION_NAME=`cat /etc/os-release | grep UBUNTU_CODENAME | awk -F= '{print $2}'`
81+
82+ # Set ROCm version
83+ ROCM_VERSION="6.1.1"
84+
85+ # Download, prepare, and install the package signing key
86+ mkdir --parents --mode=0755 /etc/apt/keyrings
87+ wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
88+
89+ # Add rocm repository
90+ wget -qO - http://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
91+ rocm_baseurl="http://repo.radeon.com/rocm/apt/${ROCM_VERSION}"
92+ echo "deb [arch=amd64] ${rocm_baseurl} ${UBUNTU_VERSION_NAME} main" | sudo tee /etc/apt/sources.list.d/rocm.list
93+ sudo apt-get update --allow-insecure-repositories
94+ sudo apt-get install -y --allow-unauthenticated \
95+ "rocm-dev${ROCM_VERSION}" "rocm-utils${ROCM_VERSION}" "rocm-libs${ROCM_VERSION}"
96+
97+ # Fake presence of MI200-class accelerators
98+ echo "gfx90a" | sudo tee /opt/rocm/bin/target.lst
99+
100+ # Cleanup
101+ sudo apt-get autoclean && sudo apt-get clean
102+ sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
103+
104+ # symblink system libraries for HIP compiler
105+ sudo ln -s /lib/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6
106+ sudo ln -s /lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/libc_nonshared.a
107+ sudo ln -s /usr/lib/x86_64-linux-gnu/libpthread.so.0 /lib64/libpthread.so.0
108+ sudo ln -s /home/runner/miniconda3/x86_64-conda-linux-gnu/sysroot/usr/lib64/libpthread_nonshared.a /usr/lib64/libpthread_nonshared.a
109+ - name : ROCm - Hipify
110+ if : inputs.rocm == 'ON'
111+ shell : bash
112+ run : ./faiss/gpu/hipify.sh
63113 - name : Build all targets
64114 shell : bash
65115 run : |
70120 -DBUILD_SHARED_LIBS=ON \
71121 -DFAISS_ENABLE_GPU=${{ inputs.gpu }} \
72122 -DFAISS_ENABLE_RAFT=${{ inputs.raft }} \
123+ -DFAISS_ENABLE_ROCM=${{ inputs.rocm }} \
73124 -DFAISS_OPT_LEVEL=${{ inputs.opt_level }} \
74125 -DFAISS_ENABLE_C_API=ON \
75126 -DPYTHON_EXECUTABLE=$CONDA/bin/python \
79130 .
80131 make -k -C build -j$(nproc)
81132 - name : C++ tests
133+ if : inputs.rocm == 'OFF'
82134 shell : bash
83135 run : |
84136 export GTEST_OUTPUT="xml:$(realpath .)/test-results/googletest/"
95147 pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
96148 pytest --junitxml=test-results/pytest/results-torch.xml tests/torch_*.py
97149 - name : Python tests (CPU + GPU)
98- if : inputs.gpu == 'ON'
150+ if : inputs.gpu == 'ON' && inputs.rocm == 'OFF'
99151 shell : bash
100152 run : |
101153 pytest --junitxml=test-results/pytest/results.xml tests/test_*.py
@@ -110,6 +162,7 @@ runs:
110162 FAISS_DISABLE_CPU_FEATURES=AVX2 LD_DEBUG=libs $CONDA/bin/python -c "import faiss" 2>&1 | grep faiss.so
111163 LD_DEBUG=libs $CONDA/bin/python -c "import faiss" 2>&1 | grep faiss_avx2.so
112164 - name : Upload test results
165+ if : inputs.rocm == 'OFF'
113166 uses : actions/upload-artifact@v4
114167 with :
115168 name : test-results-${{ runner.arch }}-${{ inputs.opt_level }}-${{ inputs.gpu }}-${{ inputs.raft }}
0 commit comments