Skip to content

Commit

Permalink
Fix compilation inside tgi (#700)
Browse files Browse the repository at this point in the history
* refactor(tgi): do not require TGI_VERSION

Since bumping the TGI version always require adapting the Dockerfile
it is useless to have it defined outside of the Dockerfile.

* fix(tgi): silent build warnings

* fix(tgi): add missing libxml2 package

This package is required by the neuronx compiler, but not pulled
automatically.
  • Loading branch information
dacorvo authored Sep 24, 2024
1 parent 8445656 commit 3748a06
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ PACKAGE_FILES = $(PACKAGE_PYTHON_FILES) \
$(PACKAGE_DIST) $(PACKAGE_WHEEL): $(PACKAGE_FILES)
python -m build

TGI_VERSION ?= 2.1.1

neuronx-tgi: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile \
--build-arg VERSION=$(VERSION) \
--build-arg TGI_VERSION=$(TGI_VERSION) \
-t neuronx-tgi:$(VERSION) .
docker tag neuronx-tgi:$(VERSION) neuronx-tgi:latest

neuronx-tgi-sagemaker: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile \
--build-arg VERSION=$(VERSION) \
--build-arg TGI_VERSION=$(TGI_VERSION) \
--target sagemaker \
-t neuronx-tgi:$(VERSION) .

Expand Down Expand Up @@ -90,7 +86,7 @@ test_installs:
tgi_server:
python -m pip install -r text-generation-inference/server/build-requirements.txt
make -C text-generation-inference/server clean
VERSION=${VERSION} TGI_VERSION=${TGI_VERSION} make -C text-generation-inference/server gen-server
VERSION=${VERSION} make -C text-generation-inference/server gen-server

tgi_test: tgi_server
python -m pip install .[neuronx]
Expand Down
12 changes: 6 additions & 6 deletions text-generation-inference/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Fetch and extract the TGI sources (TGI_VERSION is mandatory)
# Fetch and extract the TGI sources
FROM alpine AS tgi
ARG TGI_VERSION
RUN test -n ${TGI_VERSION:?}
ARG TGI_VERSION=2.1.1
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v${TGI_VERSION}.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
Expand All @@ -13,7 +12,7 @@ WORKDIR /usr/src

ARG CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse

FROM chef as planner
FROM chef AS planner
COPY --from=tgi /tgi/Cargo.lock Cargo.lock
COPY --from=tgi /tgi/Cargo.toml Cargo.toml
COPY --from=tgi /tgi/rust-toolchain.toml rust-toolchain.toml
Expand Down Expand Up @@ -100,6 +99,7 @@ RUN apt-get update -y \
aws-neuronx-collectives=2.22.26.0-17a033bc8 \
aws-neuronx-runtime-lib=2.22.14.0-6e27b8d5b \
aws-neuronx-tools=2.19.0.0 \
libxml2 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

Expand All @@ -117,7 +117,7 @@ RUN pip3 install \
hf_transfer huggingface_hub

# Install optimum-neuron
COPY dist/optimum_neuron-${VERSION}.tar.gz optimum-neuron.tar.gz
COPY ./dist/optimum_neuron-${VERSION}.tar.gz optimum-neuron.tar.gz
RUN pip3 install optimum-neuron.tar.gz

# TGI base env
Expand All @@ -134,7 +134,7 @@ COPY --from=pyserver /pyserver/build/dist dist
RUN pip install dist/text_generation_server*.tar.gz

# AWS Sagemaker compatible image
FROM neuron as sagemaker
FROM neuron AS sagemaker

COPY text-generation-inference/sagemaker-entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion text-generation-inference/server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pkg_name := text_generation_server
BUILDDIR ?= $(CURDIR)/build
VERSION ?= 0.0.1
TGI_VERSION ?= 2.0.2
TGI_VERSION ?= 2.1.1
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
pkg_dir := $(BUILDDIR)/$(pkg_name)
Expand Down

0 comments on commit 3748a06

Please sign in to comment.