Skip to content

Instantly share code, notes, and snippets.

@ddPn08
Last active February 1, 2023 18:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddPn08/6de89bf678040dbd38aaa6f093bcf5ef to your computer and use it in GitHub Desktop.
Save ddPn08/6de89bf678040dbd38aaa6f093bcf5ef to your computer and use it in GitHub Desktop.
Docker container for TensorRT Stable Diffusion Demo
FROM nvidia/cuda:11.7.0-cudnn8-devel-ubuntu20.04 as tensorrt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y \
&& apt install software-properties-common -y \
&& add-apt-repository --yes ppa:deadsnakes/ppa
RUN apt update && apt install build-essential curl git-core tensorrt tensorrt-dev tensorrt-libs -y
RUN git clone https://github.com/NVIDIA/TensorRT /TensorRT && cd /TensorRT && git submodule update --init --recursive
WORKDIR /TensorRT
RUN apt remove cmake -y \
&& curl https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.sh -L -o ./install_cmake \
&& chmod +x ./install_cmake \
&& mkdir -p /opt/cmake \
&& ./install_cmake --skip-license --prefix="/opt/cmake" \
&& ln -s /opt/cmake/bin/* /usr/bin \
&& ls -al /opt/cmake
RUN mkdir -p build && cd build \
&& cmake .. -DTRT_OUT_DIR=$PWD/out \
&& cd plugin \
&& make -j$(nproc)
FROM nvidia/cuda:11.7.0-cudnn8-devel-ubuntu20.04 as main
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y \
&& apt install software-properties-common -y \
&& add-apt-repository --yes ppa:deadsnakes/ppa
RUN apt update && apt install curl python3.10 git-core tensorrt -y \
&& curl https://bootstrap.pypa.io/get-pip.py | python3.10
RUN git clone https://github.com/NVIDIA/TensorRT /TensorRT
WORKDIR /TensorRT/demo/Diffusion
RUN pip install --upgrade pip && pip install -r requirements.txt && pip install tensorrt accelerate numpy==1.21.6
COPY --from=tensorrt /TensorRT/build/out/libnvinfer_plugin.so.8 /TensorRT/build/out/libnvinfer_plugin.so.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment