matatonic / openedai-speech

An OpenAI API compatible text to speech server using Coqui AI's xtts_v2 and/or piper tts as the backend.
GNU Affero General Public License v3.0
193 stars 32 forks source link

Fix docker build due to missing rust compiler, and compile for both platforms #18

Closed JakeStevenson closed 1 month ago

JakeStevenson commented 1 month ago

The build image did not have a rust compiler, and some of the pip packages now require it.

hchasens commented 1 month ago

Wasn't able to get this to build on M1 mac running Asahi Fedora. It would infinity hang trying to install SudachiPy. I think adding arm64 build is a great idea though!

matatonic commented 1 month ago

Can you update the Dockerfile.min also?

matatonic commented 1 month ago

Wasn't able to get this to build on M1 mac running Asahi Fedora. It would infinity hang trying to install SudachiPy. I think adding arm64 build is a great idea though!

Do you have the build logs?

hchasens commented 1 month ago

Build log is here.

matatonic commented 1 month ago

@hchasens thanks! @JakeStevenson looks like we will need gcc also, can you update it again and add gcc to the apt packages? Sorry to keep asking you to do all this, but I am a bit too busy to test anything today, thanks!

hchasens commented 1 month ago

I just tested with GCC and got another build error (build log attached). I'll play around with it a bit. I'd like to see if I can get it working by using the normal python image rather than the python-slim image as that should have more deps built in.

build.log2.txt

hchasens commented 1 month ago

Can confirm, changing base image from python3.11-slim to python.3.11 has resolved all build errors. I know it's a bit heavier, but till we can narrow down the exact missing deps this is a good solution.

matatonic commented 1 month ago

perhaps build-essential instead of gcc

hchasens commented 1 month ago

Can confirm. No build errors with python3.11-slim and adding build-essential to the apt-get command :+1: I feel a bit stupid not thinking of that. But it's solved! Yay! All upto you now @JakeStevenson!

matatonic commented 1 month ago

@JakeStevenson, @hchasens

I got access to a mac (M1) and was able to test build the -min image and confirm it's working. I made some changes to the Dockerfile so it's not larger when not needed.

FROM python:3.11-slim

ARG TARGETPLATFORM
RUN apt-get update && apt-get install --no-install-recommends -y curl ffmpeg
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then apt-get install --no-install-recommends -y build-essential ; fi
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ; fi
ENV PATH="/root/.cargo/bin:${PATH}"
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
...

I don't have the mps device working with torch in the xtts build though, any advice there would be helpful.

All current changes can be found in the dev branch.

JakeStevenson commented 1 month ago

Sorry, I don't know much about torch. I'm still figuring out the whole ecosystem around this stuff. But I'm able to run a docker image built from the dev branch and all seems well on my M2 Mac. I'm curious why you don't even need to install build-essentials on amd64, but can't test building that myself.

Thanks for working on this!