fyp/DockerfileServer

61 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2024-04-19 15:39:51 +01:00
FROM docker.io/nvidia/cuda:11.8.0-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
2024-04-22 00:09:07 +01:00
RUN apt-get install -y wget sudo pkg-config libopencv-dev unzip python3-pip vim
2024-04-19 15:39:51 +01:00
RUN pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0
RUN mkdir /go
ENV GOPATH=/go
RUN wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
RUN tar -xvf go1.22.2.linux-amd64.tar.gz -C /usr/local
ENV PATH=$PATH:/usr/local/go/bin
RUN mkdir /app
WORKDIR /app
ADD go.mod .
ADD go.sum .
ADD main.go .
ADD logic logic
RUN go install || true
WORKDIR /root
2024-04-22 00:09:07 +01:00
RUN wget https://git.andr3h3nriqu3s.com/andr3/gotch/raw/commit/22e75becf0432cda41a7c055a4d60ea435f76599/setup-libtorch.sh
2024-04-19 15:39:51 +01:00
RUN chmod +x setup-libtorch.sh
ENV CUDA_VER=11.8
2024-04-22 00:09:07 +01:00
ENV GOTCH_VER=v0.9.2
2024-04-19 15:39:51 +01:00
RUN bash setup-libtorch.sh
ENV GOTCH_LIBTORCH="/usr/local/lib/libtorch"
2024-04-22 00:09:07 +01:00
ENV REFRESH_SETUP=0
2024-04-19 15:39:51 +01:00
ENV LIBRARY_PATH="$LIBRARY_PATH:$GOTCH_LIBTORCH/lib"
ENV export CPATH="$CPATH:$GOTCH_LIBTORCH/lib:$GOTCH_LIBTORCH/include:$GOTCH_LIBTORCH/include/torch/csrc/api/include"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GOTCH_LIBTORCH/lib:/usr/lib64-nvidia:/usr/local/cuda-${CUDA_VERSION}/lib64"
2024-04-22 00:09:07 +01:00
RUN wget https://git.andr3h3nriqu3s.com/andr3/gotch/raw/branch/master/setup-gotch.sh
2024-04-19 15:39:51 +01:00
RUN chmod +x setup-gotch.sh
RUN echo 'root ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN bash setup-gotch.sh
RUN ln -s /usr/local/lib/libtorch/include/torch/csrc /usr/local/lib/libtorch/include/torch/csrc/api/include/torch
2024-04-22 00:09:07 +01:00
RUN mkdir -p /go/pkg/mod/git.andr3h3nriqu3s.com/andr3/gotch@v0.9.2/libtch/libtorch/include/torch/csrc/api
RUN find /usr/local/lib/libtorch/include -maxdepth 1 -type d | tail -n +2 | grep -ve 'torch$' | xargs -I{} ln -s {} /go/pkg/mod/git.andr3h3nriqu3s.com/andr3/gotch@v0.9.2/libtch/libtorch/include
RUN ln -s /usr/local/lib/libtorch/include/torch/csrc/api/include /go/pkg/mod/git.andr3h3nriqu3s.com/andr3/gotch@v0.9.2/libtch/libtorch/include/torch/csrc/api/include
RUN find /usr/local/lib/libtorch/include/torch -maxdepth 1 -type f | xargs -I{} ln -s {} /go/pkg/mod/git.andr3h3nriqu3s.com/andr3/gotch@v0.9.2/libtch/libtorch/include/torch
2024-04-19 15:39:51 +01:00
RUN ln -s /usr/local/lib/libtorch/lib/libcudnn.so.8 /usr/local/lib/libcudnn.so
WORKDIR /app
2024-04-22 00:09:07 +01:00
ENV CGO_CXXFLAGS="-I/usr/local/lib/libtorch/include/torch/csrc/api/include/ -I/usr/local/lib/libtorch/include"
ENV CGO_CFLAGS="-I/usr/local/lib/libtorch/include/torch/csrc/api/include/ -I/usr/local/lib/libtorch/include"
2024-04-19 15:39:51 +01:00
ADD . .
2024-04-22 00:09:07 +01:00
RUN go build -x || true
2024-04-19 15:39:51 +01:00
CMD ["bash", "-c", "go run ."]