Closed brunohanss closed 1 year ago
Just found another dockerfile using python here : https://github.com/guillaume-be/rust-bert/issues/261
But i get an error running this command
error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "/opt/conda/envs/dev/lib/python3.8/site-packages/torch/include" "-I" "/opt/conda/envs/dev/lib/python3.8/site-packages/torch/include/torch/csrc/api/include" "-Wl,-rpath=/opt/conda/envs/dev/lib/python3.8/site-packages/torch/lib" "-std=c++14" "-D_GLIBCXX_USE_CXX11_ABI=0" "-o" "/target/release/build/torch-sys-15cc74e69ce914a1/out/libtch/torch_api.o" "-c" "libtch/torch_api.cpp" with args "c++" did not execute successfully
FROM rust:latest as builder
# Install CMake
RUN apt update && apt full-upgrade -y && apt autoremove -y
# Install libtorch
RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcpu.zip && \
unzip libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip && \
rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cpu.zip
ENV LIBTORCH=/libtorch
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBTORCH/lib
RUN mkdir -p /app
# Copy the Warp Rust project into the container
WORKDIR /app
COPY . .
RUN cargo build --release
FROM rust:slim
RUN apt update && apt full-upgrade -y && apt autoremove -y
COPY --from=builder /libtorch .
RUN mkdir /app
WORKDIR /app
COPY --from=builder /app/target/release/dl-webserver .
ENV LIBTORCH=/libtorch
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBTORCH/lib
EXPOSE 3030
CMD ["/app/dl-webserver"]
This is the Dockerfile that it works with the recommended example rust-dl-webserver.
Just clone the example.
git clone https://github.com/epwalsh/rust-dl-webserver.git
cd rust-dl-webserver
Then update the cargo.toml file.
[package]
name = "dl-webserver"
version = "0.1.0"
authors = ["epwalsh <epwalsh10@gmail.com>"]
edition = "2018"
[dependencies]
batched-fn = { version = "0.2.4" }
tokio = { version = "1.14.0", features = ["full"] }
warp = "0.3.5"
tch = "0.13.0"
rust-bert = "0.21.0"
env_logger = "0.10.0"
log = "0.4"
serde = "1.0"
dirs = "5.0.1"
anyhow="1.0.72"
put the Dockerfile in the root directory of the cloned project.
Then execute the following:
docker build -t your/imagename . && docker push your/imagename
docker run -p 3030:3030 your/imagename
open another terminal and execute this query
curl -d '{"text":"Hello, World!"}' \
-H "Content-Type: application/json" \
http://localhost:3030/generate &
curl -d '{"text":"Stay at home"}' \
-H "Content-Type: application/json" \
http://localhost:3030/generate &
curl -d '{"text":"Wash your hands"}' \
-H "Content-Type: application/json" \
http://localhost:3030/generate &
curl -d '{"text":"Do not touch your face"}' \
-H "Content-Type: application/json" \
http://localhost:3030/generate &
Note: at this point you should wait a few seconds depending on your internet speed till the entire model is downloaded. And then you will get a respond back...
Great !! Thank you @samsafay
Hi, I have been trying to build my app on ubuntu using docker but i keep having major issues with libtorch
Here is my actual Dockerfile
Does someone have a valid Dockerfile ready to use or any advice to make my file works ? That would be greatly appreciated