Applications on Beta9 are run inside containers. A container is a lightweight VM that packages a set of software packages required by your application.
Containers are based on container images which are instructions for how a container should be built.
Because you are building a custom application, it is likely that your application depends on some custom software to run.
You can customize the container image used to run your Beta9 application with the Image
parameter.
Beta9 containers have two defaults to be aware of:Default Container OS: Ubuntu 20.04Default CUDA: CUDA 12.2
Adding custom base images
You can import existing images from remote Docker registries, like Dockerhub, Google Artifact Registry, ECR, Github Container Registry, Nvidia and more.
Just supply a base_image
argument to Image
.
from beta9 import endpoint, Image
image = (
Image(
python_version="python3.9",
python_packages=[
"transformers",
"torch",
],
commands=["apt-get update -y && apt-get install ffmpeg -y"],
base_image="docker.io/nvidia/cuda:12.3.1-runtime-ubuntu20.04",
),
)
@endpoint(cpu=1, memory="16Gi", gpu="T4", image=image)
def handler():
return {}
Beta9 only supports Debian-based images.
Adding shell commands
You can also run any shell commands you want in the environment before it starts up. Just pass them into the commands
field in your app definition.
Below, we’ll customize our image with requests
and some shell commands:
from beta9 import endpoint, Image
image = (
Image(
python_version="python3.9",
python_packages=["requests"],
commands=["apt-get update && pip install beautifulsoup4"],
),
)
@endpoint(cpu=1, memory="16Gi", gpu="T4", image=image)
def handler():
return {}
Adding Python packages
You can add Python packages to the runtime in the python_packages
field:
from beta9 import Image
image = (
Image(
python_version="python3.9",
python_packages=["requests"],
),
)
Beta9 will default to Python 3.8 if no python_version
is provided.
Alternatively, you can pass in a path to a requirements.txt
file:
from beta9 import Image
image = (
Image(
python_packages="requirements.txt",
),
)