Skip to content

Commit

Permalink
Add dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongkaifu committed Nov 30, 2023
1 parent 69322f7 commit 57b49fe
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,13 @@ Here is the configuration file for model training.

# Demos and released models
From 2.7.0 version, Seq2SeqSharp models are deployed on Hugging Face and you can also play demos there.
| Demo | Hugging Face Space Url | Hugging Face Model Url | Model Parameters |
| ------------------------------------------------------ | ------------------------------------------------------- | ----------------------------------------------- | --------------------------------------------- |
| Machine Translation from English to Chinese | https://huggingface.co/spaces/zhongkaifu/mt_enu_chs | https://huggingface.co/zhongkaifu/mt_enu_chs | 117M (6 encoder layers and 6 decoder layers) |
| Machine Translation from Chinese to English | https://huggingface.co/spaces/zhongkaifu/mt_chs_enu | https://huggingface.co/zhongkaifu/mt_chs_enu | 117M (6 encoder layers and 6 decoder layers) |
| Machine Translation from Japanese or Korean to Chinese | https://huggingface.co/spaces/zhongkaifu/mt_jpnkor_chs | https://huggingface.co/zhongkaifu/mt_jpnkor_chs | 117M (6 encoder layers and 6 decoder layers) |
| Chinese Medical Question and Answer Demo | https://huggingface.co/spaces/zhongkaifu/medical_qa_chs | https://huggingface.co/zhongkaifu/qa_med_chs | 117M (6 encoder layers and 6 decoder layers) |
| Chinese fiction writer | https://huggingface.co/spaces/zhongkaifu/story_writing | https://huggingface.co/zhongkaifu/story_writing | 762M (36 decoder layers only, GPT type model) |
| Demo | Hugging Face Space Url | Hugging Face Model Url | Model Parameters |
| ------------------------------------------------------ | ------------------------------------------------------- | ----------------------------------------------- | ----------------------- |
| Machine Translation from English to Chinese | https://huggingface.co/spaces/zhongkaifu/mt_enu_chs | https://huggingface.co/zhongkaifu/mt_enu_chs | 117M (Encoder-Decoder) |
| Machine Translation from Chinese to English | https://huggingface.co/spaces/zhongkaifu/mt_chs_enu | https://huggingface.co/zhongkaifu/mt_chs_enu | 117M (Encoder-Decoder) |
| Machine Translation from Japanese or Korean to Chinese | https://huggingface.co/spaces/zhongkaifu/mt_jpnkor_chs | https://huggingface.co/zhongkaifu/mt_jpnkor_chs | 117M (Encoder-Decoder) |
| Chinese Medical Question and Answer Demo | https://huggingface.co/spaces/zhongkaifu/medical_qa_chs | https://huggingface.co/zhongkaifu/qa_med_chs | 117M (Encoder-Decoder) |
| Chinese fiction writer | https://huggingface.co/spaces/zhongkaifu/story_writing | https://huggingface.co/zhongkaifu/story_writing | 2B (Decoder only) |

To deploy binary files and models, you can check Dockerfile in Hugging Face Space urls or "Build & Deployment" section in this document.

Expand Down
53 changes: 53 additions & 0 deletions Tools/SeqWebApps/Dockers/Dockerfile_CPU.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.9

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

RUN wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN rm packages-microsoft-prod.deb

RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh

RUN apt-get update
RUN apt-get install -y dotnet-sdk-7.0
RUN apt-get install -y aspnetcore-runtime-7.0
RUN apt-get install -y cmake
RUN apt-get install -y git-lfs

RUN git clone https://github.com/zhongkaifu/Seq2SeqSharp.git
WORKDIR /code/Seq2SeqSharp
RUN dotnet build Seq2SeqSharp.sln --configuration Release

WORKDIR /code/Seq2SeqSharp/ExternalProjects
RUN unzip SentencePiece.zip
WORKDIR /code/Seq2SeqSharp/ExternalProjects/SentencePiece
RUN mkdir build
WORKDIR /code/Seq2SeqSharp/ExternalProjects/SentencePiece/build
RUN cmake ..
RUN make -j $(nproc)
RUN make install
RUN ldconfig -v

WORKDIR /code

#RUN git clone https://huggingface.co/zhongkaifu/mt_enu_chs

RUN mkdir -p /code/bin
RUN chmod 777 /code/bin
WORKDIR /code/bin

RUN cp -r /code/Seq2SeqSharp/Tools/SeqWebApps/bin/Release/net7.0/* .
RUN wget https://huggingface.co/zhongkaifu/mt_enu_chs/resolve/main/mt_enu_chs.model
RUN wget https://huggingface.co/zhongkaifu/mt_enu_chs/resolve/main/chsSpm.model
RUN rm appsettings.json
RUN wget https://huggingface.co/zhongkaifu/mt_enu_chs/resolve/main/appsettings.json
#RUN cp /code/mt_enu_chs/appsettings.json .

CMD ["dotnet","/code/bin/SeqWebApps.dll"]
63 changes: 63 additions & 0 deletions Tools/SeqWebApps/Dockers/Dockerfile_GPU.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM nvidia/cuda:12.3.0-base-ubuntu22.04

WORKDIR /code

RUN apt-get update
RUN apt install -y zip

# Install .NET SDK
RUN apt-get update
RUN apt-get install -y dotnet-sdk-7.0
RUN apt-get install -y aspnetcore-runtime-7.0
RUN apt-get install -y cmake
RUN apt-get install -y git-lfs

RUN cat /etc/os-release
RUN apt-get install -y software-properties-common

# Install Cuda
RUN apt install wget
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
RUN dpkg -i cuda-keyring_1.1-1_all.deb
RUN apt-get update
RUN apt-get -y install cuda-toolkit-12-3

# Clone Seq2SeqSharp
RUN git clone https://github.com/zhongkaifu/Seq2SeqSharp.git
WORKDIR /code/Seq2SeqSharp
RUN dotnet build Seq2SeqSharp.sln --configuration Release

RUN apt-get install -y build-essential

# Build customized SentencePiece
WORKDIR /code/Seq2SeqSharp/ExternalProjects
RUN unzip SentencePiece.zip
WORKDIR /code/Seq2SeqSharp/ExternalProjects/SentencePiece
RUN mkdir build
WORKDIR /code/Seq2SeqSharp/ExternalProjects/SentencePiece/build
RUN cmake ..
RUN make -j $(nproc)
RUN make install
RUN ldconfig -v

WORKDIR /code

RUN mkdir -p /code/bin
RUN chmod 777 /code/bin
WORKDIR /code/bin

# Deploy models, vocabulary and config files
RUN cp -r /code/Seq2SeqSharp/Tools/SeqWebApps/bin/Release/net7.0/* .
RUN wget https://huggingface.co/zhongkaifu/story_writing/resolve/main/ybook_2b.model.415000
RUN wget https://huggingface.co/zhongkaifu/story_writing/resolve/main/chsSpm.model
RUN wget https://huggingface.co/zhongkaifu/story_writing/resolve/main/Map_SC_TC.txt
RUN rm appsettings.json
RUN wget https://huggingface.co/zhongkaifu/story_writing/resolve/main/appsettings.json

# ENV MKL_ENABLE_INSTRUCTIONS=AVX2

# Run application
CMD ["dotnet","/code/bin/SeqWebApps.dll"]

0 comments on commit 57b49fe

Please sign in to comment.