Skip to main content

BentoML

Structure

The simplest BentoML model package has the following structure:

├── bentofile.yaml
├── requirements.txt
├── packages.txt
└── service.py

Environment

In the BentoML deployment environment, Python 3.10 is used based on the buildpack-deps:jammy (Ubuntu 22.04). The unpacked model will be located in /user/model.

Aptitude

You can install packages using the Linux package manager apt-get. You can list the packages to be installed in packages.txt, one per line.

ffmpeg
libopenal1

The packages listed in packages.txt will be installed on the system using the following command:

xargs sudo apt-get --no-install-recommends -y install < packages.txt

Virtualenv

The environment preparation script only installs the pip packages listed in requirements.txt. bentoml must be included in requirements.txt.

pip install --no-cache-dir -r requirements.txt

To list all packages installed in the current environment, you can use the command below:

pip freeze > requirements.txt

BentoML

In the execution container, BentoML is run using the following command. You can verify that it works the same way in your local environment.

bentoml serve /user_model --host 0.0.0.0 --p 8080

For more details on writing models based on BentoML, please refer to the BentoML docs.