Skip to content

Commit e314841

Browse files
committed
chore(ci): fix OOM when linking c_api tests
1 parent 6719810 commit e314841

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/c_api_tests.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,29 @@ REPO_ROOT="${CURR_DIR}/.."
4949
TFHE_BUILD_DIR="${REPO_ROOT}/tfhe/build/"
5050
CPU_COUNT="$("${CURR_DIR}"/cpu_count.sh)"
5151

52+
53+
54+
LINKING_CPU_COUNT=4
55+
56+
# On linux
57+
if [[ $(uname) != "Darwin" ]]; then
58+
mem_in_gb="$(free -g | awk '/Mem:/ {print $2}')"
59+
60+
# If there is more than 100GB on the system,
61+
# use all available cores for linking
62+
# Otherwise, only use 4, to avoid OOM when linking
63+
if [ 100 -lt "$mem_in_gb" ]; then
64+
LINKING_CPU_COUNT="$(CPU_COUNT)"
65+
fi
66+
fi
67+
5268
mkdir -p "${TFHE_BUILD_DIR}"
5369

5470
cd "${TFHE_BUILD_DIR}"
5571

5672
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCARGO_PROFILE="${CARGO_PROFILE}" -DWITH_FEATURE_GPU="${WITH_FEATURE_GPU}"
5773

58-
make -j "${CPU_COUNT}"
74+
make -j "${LINKING_CPU_COUNT}"
5975

6076
if [[ "${BUILD_ONLY}" == "1" ]]; then
6177
exit 0

0 commit comments

Comments
 (0)