Skip to content

Commit

Permalink
Round HQ cpu to integer
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Aug 13, 2024
1 parent 703ec8b commit 71b1dc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions before-notebook.d/42_start-hq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ CPU_PERIOD=$(awk '{print $2}' /sys/fs/cgroup/cpu.max)
if [ "$CPU_PERIOD" -ne 0 ]; then
CPU_NUMBER=$(echo "scale=2; $CPU_LIMIT / $CPU_PERIOD" | bc)
echo "Number of CPUs allocated: $CPU_NUMBER"

# for HQ setting round to integer number of CPUs, the left are for system tasks
HQ_CPU_NUMBER=$(echo "scale=0; $CPU_LIMIT / $CPU_PERIOD" | bc)
else
# if no limit (with local OCI without setting cpu limit, use all CPUs)
CPU_NUMBER=$(nproc)
HQ_CPU_NUMBER=$(nproc)
echo "No CPU limit set"
fi

# Start hq server with a worker
run-one-constantly hq server start 1>$HOME/.hq-stdout 2>$HOME/.hq-stderr &
run-one-constantly hq worker start --cpus=${CPU_NUMBER} --resource "mem=sum(${LOCAL_MEM})" --no-detect-resources &
run-one-constantly hq worker start --cpus=${HQ_CPU_NUMBER} --resource "mem=sum(${LOCAL_MEM})" --no-detect-resources &

0 comments on commit 71b1dc5

Please sign in to comment.