serve icon indicating copy to clipboard operation
serve copied to clipboard

Docker build on M1 fails

Open c-xlenz opened this issue 3 years ago • 6 comments

Please have a look at FAQ's and Troubleshooting guide, your query may be already addressed.

Your issue may already be reported! Please search on the issue tracker before creating one.

Context

  • torchserve version: 0.5.0
  • torch version: 1.10.0+cpu
  • Operating System and version: Mac OS 12.0.1

Possible Solution

I think the correct package is missing on pypi.

Steps to Reproduce

trying to build it on a Mac M1 with: ./build_image.sh

Failure Logs [if any]

=> ERROR [compile-image 6/7] RUN TORCH_VER=$(curl --silent --location https://pypi.org/pypi/torch/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && TORCH_VISION_VER=$(curl --silent --location https://pypi.org/pypi/torchvision/json | python 7.8s

[compile-image 6/7] RUN TORCH_VER=$(curl --silent --location https://pypi.org/pypi/torch/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && TORCH_VISION_VER=$(curl --silent --location https://pypi.org/pypi/torchvision/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && if echo "ubuntu:18.04" | grep -q "cuda:"; then if [ "" ]; then pip install --no-cache-dir torch==$TORCH_VER+ torchvision==$TORCH_VISION_VER+ -f https://download.pytorch.org/whl/torch_stable.html; else pip install --no-cache-dir torch torchvision; fi else pip install --no-cache-dir torch==$TORCH_VER+cpu torchvision==$TORCH_VISION_VER+cpu -f https://download.pytorch.org/whl/torch_stable.html; fi: #13 2.068 Collecting torch==1.10.0+cpu #13 7.510 Could not find a version that satisfies the requirement torch==1.10.0+cpu (from versions: 1.9.0) #13 7.511 No matching distribution found for torch==1.10.0+cpu

c-xlenz avatar Dec 13 '21 16:12 c-xlenz

AFAIK Pytorch isn's supported natively on M1 - you can follow this thread for updates https://github.com/pytorch/pytorch/issues/47702

msaroufim avatar Dec 14 '21 22:12 msaroufim

Thanks. But ... the problem is not in M1 directly. That works fine!

It is more the version that is required in the used ubuntu version in the docker is not available...

c-xlenz avatar Dec 20 '21 16:12 c-xlenz

I'm sorry I'm being a bit slow. Is your issue that when you're using the dockerhub torchserve image that the pytorch version that comes bundled with it doesn't work on M1? I just can't easily repro since I don't have an M1 so want to make sure I clearly understand the problem.

If it's a wrong torch version and you're building an image from scratch, consider changing the requirements.txt that you need for your specific platform and cuda version here https://github.com/pytorch/serve/tree/master/requirements

msaroufim avatar Feb 09 '22 23:02 msaroufim

Thanks @msaroufim.

I think the issue is, that torch serve is not being built when you build the docker image. Instead it installs it from pypi

image

This might lead to the problem, that you have not the right package at hand for a ubuntu running on a M1 arm architecture.

image

Surely, I can spawn my own docker image with ubuntu, build it and layer it in... but it should be part of the docker image build... at least as an option.

Additionally, on current 0.5.2, you are using image

18.04 as base image. This leads to build errors as it contains python 3.6 and some packages used require a newer version.

with 20.04 as base image it works (until trying to find and install torch serve)

I might be wrong with this... just let me know

c-xlenz avatar Feb 10 '22 10:02 c-xlenz

Change os architecture for build-

docker buildx build --platform=linux/amd64 -t xyz .

rahulcodewiz avatar Apr 29 '22 00:04 rahulcodewiz

Do you wanna make the PR to address this case in our docker file and docker file dev or README

msaroufim avatar Apr 29 '22 03:04 msaroufim