Skip to main content

Backend.AI Kernel Runner based on GNU libc

Project description

backend.ai-krunner-static-gnu

Backend.AI Kernel Runner Package for glibc-based Kernels

This package contains a statically built Python distribution and 3rd-party libraries required to run our krunner module inside containers whose images are provided by users.

The krunner wheel itself can be installed into any Python environments (the content of this plugin package is agnostic to platforms and architectures as it's a mere declaration of the plugin interface), but we still apply the binary wheel platform tags so that setuptools could distinguish the target CPU architecture as follows:

Where is Backend.AI running? What is the user container's base image? The krunner wheel used
manylinux (x86-64) manylinux (x86-64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
manylinux (x86-64) musllinux (x86-64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
manylinux (aarch64) manylinux (aarch64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
manylinux (aarch64) musllinux (aarch64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
musllinux (x86-64) manylinux (x86-64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
musllinux (x86-64) musllinux (x86-64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
musllinux (aarch64) manylinux (aarch64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
musllinux (aarch64) musllinux (aarch64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
macOS (x86-64) manylinux (x86-64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
macOS (x86-64) musllinux (x86-64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
macOS (aarch64) manylinux (aarch64) backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
macOS (aarch64) musllinux (aarch64) backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl

We named the krunner package based on musl 1.2 as "alpine" because practically Alpine linux is the only distribution which actively uses musl and it is currently not possible to build static CPython which can import 3rd-party dynamic modules on top of the musl ecosystem.

Notice about source distribution

This package is to distribute prebuilt binaries, so the source distribution does not have prebuilt binaries and does not work as intended. Just refer this repository on how we build stuffs.

How to read below

  • {distro} is a string like static-gnu, alpine, etc. depending on which repository you are in.
  • {distro_} is a string same to {distro} but with hyphens replaced with underscores for Python package names and paths. (e.g., static_gnu, alpine)

Development

$ git clone https://github.com/lablup/backend.ai-krunner-{distro} krunner-{distro}
$ cd krunner-{distro}
$ pyenv virtualenv 3.12.2 venv-krunner  # you may share the same venv with other krunner projects
$ pyenv local venv-krunner
$ pip install -U pip setuptools
$ pip install -U -r build/requirements.txt
$ pip install -U -e .

How to update

  1. Modify Dockerfile and/or other contents.
  • To update the Python version, update src/ai/backend/krunner/{distro_}/krunner-python.{distro}.txt and the dockerfiles (both python and wheels) accordingly, including the PYTHON_VERSION environment variable and the download URL of the statically built Python distribution.
  1. Increment the volume version number specified as a label ai.backend.krunner.version in src/ai/backend/krunner/{distro_}/krunner-env.{distro}.dockerfile
  2. Run scripts/build.py.
  3. Repeat the above steps for each distro version. (For static builds, there is only one.)
  4. Increment the package version number in src/ai/backend/krunner/{distro_}/__init__.py
  5. rm -r dist/* build/* (skip if these directories do not exist and or are empty)
  6. Commit.
  7. Create a signed annotated tag and push the tag to let GitHub Action build and publish wheels.

Note that src/ai/backend/krunner/{distro_}/krunner-version.{distro}.txt files are overwritten by the build script from the label.

WARNING: We should choose x86_64_v2 binaries from the indygreg repository when updating the Python runtime version for CPU compatibility with some of our test setups and customer sites.

Making a minimal glibc-based image compatibile with this krunner package

Use CentOS 7 or later and install this list of packages. Also refer the test script.

Build custom ttyd binary

⚠️ Warning: Use a x86-64 host to build ttyd, because:

  • ttyd uses musl as their C stdlib, not glibc.
  • The musl toochain used by the build script is x86_64 binaries.

libwebsockets>=4.0.0 features auto ping/pong with 5 min default interval. (https://github.com/warmcat/libwebsockets#connection-validity-tracking) And, ws_ping_pong_interval of ttyd is not effective in libwebsockets>=4.0.0. This seems to be the reason why ttyd>=1.6.1 does not set ws_ping_pong_interval for libwebsockets>=4.0.0. (https://github.com/tsl0922/ttyd/blob/master/src/server.c#L456)

To fix this issue, we modify and build the latest version of libwebsockets used by the ttyd build script manually.

# Prepare Ubuntu environment (possibly, through container) and dependencies.
sudo apt-get update
sudo apt-get install -y autoconf automake build-essential cmake curl file libtool

# Download ttyd source.
git clone https://github.com/tsl0922/ttyd.git
cd ttyd

Now let's modify ./scripts/cross-build.sh.
Add these two lines under pushd "${BUILD_DIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}":

sed -i 's/context->default_retry.secs_since_valid_ping = 300/context->default_retry.secs_since_valid_ping = 20/g' lib/core/context.c 
sed -i 's/context->default_retry.secs_since_valid_hangup = 310/context->default_retry.secs_since_valid_hangup = 30/g' lib/core/context.c 

Finally, build the ttyd binary.

# Run build script.
./scripts/cross-build.sh

# Check ttyd binary version.
./build/ttyd --version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backend.ai-krunner-static-gnu-4.2.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distributions

backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl (49.5 MB view details)

Uploaded Python 3 macOS 11.0+ x86-64 musllinux: musl 1.1+ x86-64

backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl (48.2 MB view details)

Uploaded Python 3 macOS 11.0+ ARM64 musllinux: musl 1.1+ ARM64

File details

Details for the file backend.ai-krunner-static-gnu-4.2.0.tar.gz.

File metadata

File hashes

Hashes for backend.ai-krunner-static-gnu-4.2.0.tar.gz
Algorithm Hash digest
SHA256 62f7977362d3ce87da17af122f82681a55f3d2e1cd3b6c5a8eec084ad02e82cc
MD5 f204c8e6e7c3b1b68548f0c28981c79e
BLAKE2b-256 5c7e564dbe5383b57992c0a17521caa38f7e189d894c51458070b11755f739b0

See more details on using hashes here.

Provenance

File details

Details for the file backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 81ce53a067293f4ed4935b8b6b918fdf6fbb72666202b14b2f1e3afc6f7a62fc
MD5 b400413562e5b38936c72863fe7b4f45
BLAKE2b-256 0a47cd80ec9dad98008cebbe019b0ad01569964a6e84e377b36725bf757e9564

See more details on using hashes here.

Provenance

File details

Details for the file backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for backend.ai_krunner_static_gnu-4.2.0-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a24afa18a7a2c549461aa5f8857333e133fd1349009e4b078bf358e157138f9
MD5 c0837e65f93e2e98da6f2ceaecda0c10
BLAKE2b-256 dc526be9de312bcbd60f4d2b8348424b3e2e7413ae3d9dab6ac6bd7a329653bb

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page