diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 00000000..51ab355e --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,75 @@ +FROM ubuntu:24.04 + +# Install prerequisites (including gcc, g++, glibc, cmake, make, ninja, and python3) +# Latest available gcc and g++ are installed - should we be specific about the version? +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + lsb-release \ + software-properties-common \ + gnupg \ + curl \ + git \ + build-essential \ + cmake \ + ninja-build \ + python3 \ + python3-pip \ + python3-venv \ + wget + +# Install LLVM 20 +RUN wget https://apt.llvm.org/llvm.sh && \ + chmod +x llvm.sh && \ + ./llvm.sh 20 && \ + rm -rf llvm.sh + +RUN ln -s /usr/bin/clang-20 /usr/bin/clang && \ + ln -s /usr/bin/clang++-20 /usr/bin/clang++ + +ENV CC=clang +ENV CXX=clang++ + +# Install .NET Core SDK and Runtime - 9.0 +RUN add-apt-repository ppa:dotnet/backports + +RUN apt-get install -y \ + dotnet-sdk-9.0 + +# Install Rust (Latest stable version - should we be specific about the version?) +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + --no-modify-path \ + --default-toolchain stable \ + --no-self-update + +ENV PATH="/root/.cargo/bin:$PATH" + +# Install Zig 0.14.1 +ENV ZIG_VERSION=0.14.1 +ENV ZIG_HOME=/opt/zig + +RUN curl -LO https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz && \ + tar -xf zig-x86_64-linux-${ZIG_VERSION}.tar.xz && \ + mv zig-x86_64-linux-${ZIG_VERSION} ${ZIG_HOME} && \ + ln -s ${ZIG_HOME}/zig /usr/bin/zig && \ + rm zig-x86_64-linux-${ZIG_VERSION}.tar.xz + +# Clone the OpenBench Client +RUN git clone https://github.com/AndyGrant/OpenBench + +# Fetch the OpenBench Client startup script +COPY run.sh /OpenBench/Client/run.sh + +RUN python3 -m venv /.venv + +ENV PATH="/.venv/bin:$PATH" + +# Set the working directory to the OpenBench Client +WORKDIR /OpenBench/Client + +# Install OpenBench Client dependencies +RUN pip install --upgrade pip && \ + pip install -r requirements.txt + +# Execute the OpenBench Client startup script +CMD ["bash", "run.sh"] \ No newline at end of file diff --git a/Docker/run.sh b/Docker/run.sh new file mode 100644 index 00000000..f58509f2 --- /dev/null +++ b/Docker/run.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +if [ -z "$OPENBENCH_USERNAME" ]; +then + echo "Username is not set. Please set the OPENBENCH_USERNAME variable." + exit 1 +fi + +if [ -z "$OPENBENCH_PASSWORD" ]; +then + echo "Password is not set. Please set the OPENBENCH_PASSWORD variable." + exit 1 +fi + +if [ -z "$OPENBENCH_SERVER" ]; +then + echo "Server is not set. Please set the OPENBENCH_SERVER variable." + exit 1 +fi + +SOCKETS=$(lscpu | awk -F: '/^Socket\(s\):/ { gsub(/ /,"",$2); print $2; exit }') + +if [ -z "$SOCKETS" ]; +then + echo "Error: could not detect Socket(s) from lscpu" >&2 + exit 1 +fi + +# This formula is ideal for selecting the correct number of threads for high number of cores, leaving enough leeway for +# Cutechess to not be subjected to time-losses. +# However, it may not be optimal for low core counts - would love to hear feedback on possible adjustments +THREADS=$( + awk -v N="$(nproc)" -v S="$SOCKETS" 'BEGIN { + t = N - int(0.75 * sqrt(N)) + printf "%d", t - (t % S) + }' +) + +exec python client.py \ + --username "$OPENBENCH_USERNAME" \ + --password "$OPENBENCH_PASSWORD" \ + --threads "$THREADS" \ + --nsockets "$SOCKETS" \ + --server "$OPENBENCH_SERVER" \ + -I "$(hostname)" \ No newline at end of file