bentoml / gallery

BentoML Example Projects 🎨
https://bentoml.com
134 stars 50 forks source link

feat: Tensorflow 2.x gallery project #112

Closed timliubentoml closed 2 years ago

timliubentoml commented 2 years ago

Walked through the example, which mostly worked up until the end when we are trying to containerize the bento. Currently when running on a mac, it looks like for M1 laptops you have to use tensorflow-macos. This generally works and I've added instructions where the installation/example slightly diverges for M1 machines. However when building the bento on an M1, building it only works if using the "tensorflow-macos" library dependency in the bentofile-macos.yaml file. However, when containerizing the bento we get this error:

13 26.83 ERROR: Could not find a version that satisfies the requirement tensorflow-macos==2.8.0 (from versions: none)

13 26.83 ERROR: No matching distribution found for tensorflow-macos==2.8.0

Presumable because the docker environment which is the bento is being containerized into does not use tensorflow-macos, but needs the standard library. However we can't build the bento locally on an M1 machine to get this to work.

aarnphm commented 2 years ago

for bentofile.yaml I don't think we need to include on for MacOS. You can add lock_packages: false, which will bypass locking python version for building bento. I think when building bento, users will run it under a linux container anw

service: "service:svc"
description: "file: ./README.md"
labels:
  owner: bentoml-team
  stage: demo
include:
- "*.py"
exclude:
- "locustfile.py"
- "tests/"
- "models/"
- "*.ipynb"
python:
  lock_packages: false
  packages:
    - tensorflow
timliubentoml commented 2 years ago

for bentofile.yaml I don't think we need to include on for MacOS. You can add lock_packages: false, which will bypass locking python version for building bento. I think when building bento, users will run it under a linux container anw

service: "service:svc"
description: "file: ./README.md"
labels:
  owner: bentoml-team
  stage: demo
include:
- "*.py"
exclude:
- "locustfile.py"
- "tests/"
- "models/"
- "*.ipynb"
python:
  lock_packages: false
  packages:
    - tensorflow

@aarnphm This solution almost worked. Now when I try to run the container, it blows up and complains that it wasn't compiled in the right architecture... Going to try messing with that a little:

The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine. qemu: uncaught target signal 6 (Aborted) - core dumped

aarnphm commented 2 years ago

The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine. qemu: uncaught target signal 6 (Aborted) - core dumped AVX is only available on x64 machine. I think if you can change the architecture of the container to use --platform linux/amd64 it might work?