transformers-nlp-service icon indicating copy to clipboard operation
transformers-nlp-service copied to clipboard

Bug: BentoML config file specification in bentofile.yaml causes filenotfound error when using it containerised

Open hugocool opened this issue 2 years ago • 3 comments
trafficstars

There is an issue in the specification of the bentofile.yaml file, specifically in the docker section where the env entry is defined. When the BENTOML_CONFIG environment variable is specified in the env entry, the BentoML service fails to start in a Docker container.

Steps to reproduce: git clone this repo, keep the bentofile.yml as is (so the BENTOML_CONFIG environment variable in the env entry of the bentofile.yaml file is defined as /.config/default.yaml Build and containerize the BentoML service using the bentoml build and bentoml containerize commands.

ECR_REPO=...
TAG=latest
SERVICE_NAME=transformers-nlp-service-gpu

bentoml build && bentoml containerize "${SERVICE_NAME}" -t "${ECR_REPO}:${TAG}"

Run the Docker container using the docker run command.

docker run --rm -p 3000:3000 "${ECR_REPO}:${TAG}"

Expected behavior:

The BentoML service should start in the Docker container without any issues.

Actual behavior:

The BentoML service fails to start in the Docker container and the following error message is displayed:

Traceback (most recent call last): File "/usr/local/bin/bentoml", line 5, in from bentoml_cli.cli import cli File "/usr/local/lib/python3.9/site-packages/bentoml_cli/cli.py", line 57, in cli = create_bentoml_cli() File "/usr/local/lib/python3.9/site-packages/bentoml_cli/cli.py", line 20, in create_bentoml_cli from bentoml._internal.context import component_context File "/usr/local/lib/python3.9/site-packages/bentoml/init.py", line 25, in load_config() File "/usr/local/lib/python3.9/site-packages/bentoml/_internal/configuration/init.py", line 143, in load_config raise FileNotFoundError( FileNotFoundError: BentoML config file specified in ENV VAR not found: 'BENTOML_CONFIG=./config/default.yaml'

Proposed solution: Update the bentofile.yaml file to remove the env entry and provide instructions on how to set the BENTOML_CONFIG environment variable when running the Docker container.

versions

python 3.9.11 os: ubuntu 24 bentoml 1.1.6

hugocool avatar Sep 13 '23 16:09 hugocool

Hi @hugocool - could you share your bentofile.yaml? Did you include the ./config/default.yaml file in the include section?

parano avatar Sep 13 '23 17:09 parano

this happened right after cloning this exact repo from the main brach. So the bentofile.yaml is exactly as it is in this repo:

service: 'service.py:svc'
name: transformers-nlp-service
labels:
  owner: bentoml-team
  project: transformers-nlp-service
include:
  - '*.py'
  - '/tests'
  - 'pyproject.toml'
  - '/config'
python:
  requirements_txt: requirements/tests.txt
docker:
  dockerfile_template: ./Dockerfile.template
  system_packages:
    - 'git'
  env:
    BENTOML_CONFIG: ./config/default.yaml

and so if the the ./config/default.yaml file is in the include section in this repo, it was in mine.

I also checked the bentos directory and the /home/ec2-user/bentoml/bentos/transformers-nlp-service-gpu/.../bento.yaml contained:

docker:
  distro: debian
  python_version: '3.9'
  cuda_version: 11.6.2
  env:
    BENTOML_CONFIG: ./config/default.yaml

and the default.yaml was located at: .../src/config/default.yaml

hugocool avatar Sep 13 '23 17:09 hugocool

I make to fix it with : BENTOML_CONFIG is not correctly configured, it should be BENTOML_CONFIG=./src/config/default.yaml

docker run -p 3000:3000 -e BENTOML_CONFIG=./src/config/default.yaml ghcr.io/bentoml/transformers-nlp-service:cpu

ArianeFire avatar Mar 03 '25 16:03 ArianeFire