-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.amd64_cpu
116 lines (101 loc) · 3.38 KB
/
Dockerfile.amd64_cpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
FROM carml/base:amd64-cpu-latest
MAINTAINER Abdul Dakkak <[email protected]>
# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG VCS_URL
ARG VERSION
ARG ARCH
ARG FRAMEWORK_VERSION
LABEL org.carml.go-pytorch.build-date=$BUILD_DATE \
org.carml.go-pytorch.name="go-pytorch bindings for go" \
org.carml.go-pytorch.description="" \
org.carml.go-pytorch.url="https://www.mlmodelscope.org/" \
org.carml.go-pytorch.vcs-ref=$VCS_REF \
org.carml.go-pytorch.vcs-url=$VCS_URL \
org.carml.go-pytorch.vendor="MLModelScope" \
org.carml.go-pytorch.arch=$ARCH \
org.carml.go-pytorch.version=$VERSION \
org.carml.go-pytorch.framework_version=$FRAMEWORK_VERSION \
org.carml.go-pytorch.schema-version="1.0"
########## DEPENDENCIES INSTALLATION ###################
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libgoogle-glog-dev \
libboost-all-dev \
libgtest-dev \
libprotobuf-dev \
protobuf-compiler \
libgflags-dev \
libiomp-dev \
libleveldb-dev \
liblmdb-dev \
libopencv-dev \
libopenmpi-dev \
libsnappy-dev \
openmpi-bin \
openmpi-doc \
libeigen3-dev \
python-dev \
python-pip \
python-setuptools \
python-yaml \
tzdata && \
rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir numpy &&\
pip install --no-cache-dir typing
RUN ln -fs /usr/share/zoneinfo/America/Chicago /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata
########## LIBRARY INSTALLATION ###################
WORKDIR /opt
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
# SOURCE INSTALLATION
ENV PYTORCH_DIST_DIR /opt/libtorch
ARG BRANCH=v1.3.0
RUN git clone --single-branch --depth=1 --recurse-submodules --branch=${BRANCH} https://github.com/pytorch/pytorch.git && cd pytorch && \
git submodule update --init && \
mkdir build && cd build && \
cmake .. \
-DCMAKE_INSTALL_PREFIX=$PYTORCH_DIST_DIR \
-DBUILD_TORCH=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=1" \
-DUSE_OBSERVERS=ON \
-DUSE_PROF=ON \
-DBLAS=OpenBLAS \
-DBUILD_CUSTOM_PROTOBUF=ON \
-DBUILD_PYTHON=ON \
-DUSE_NATIVE_ARCH=ON \
-DUSE_NNPACK=ON \
-DUSE_OPENCV=OFF \
-DUSE_MKL=OFF \
-DUSE_DISTRIBUTED=OFF \
-DUSE_ROCKSDB=OFF \
-DUSE_GLOO=OFF \
-DUSE_NCCL=OFF \
-DUSE_CUDA=OFF \
&& make -j$(nproc) install \
&& ldconfig \
&& make clean \
&& cd .. \
&& rm -rf build
### Built-in method to build custom libtorch
#RUN git clone --single-branch --depth=1 --recurse-submodules --branch=$FRAMEWORK_VERSION https://github.com/pytorch/pytorch.git && cd pytorch && \
# git submodule update --init && \
# cd tools && \
# ls -l && \
# python build_libtorch.py && \
# cd ../torch && \
# ls -l && \
# ls -l ./lib && \
RUN echo "$PYTORCH_DIST_DIR/lib" >> /etc/ld.so.conf.d/libtorch.conf && ldconfig
ENV LD_LIBRARY_PATH /opt/libtorch/lib:${LD_LIBRARY_PATH}
########## GO BINDING INSTALLATION ###################
ENV PKG github.com/rai-project/go-pytorch
WORKDIR $GOPATH/src/$PKG
RUN git clone --depth=1 --single-branch --branch=master https://${PKG}.git .
RUN dep ensure -v -no-vendor -update \
github.com/rai-project/dlframework && \
dep ensure -v -vendor-only
RUN go install -a -tags=nogpu -installsuffix cgo -ldflags "-s -w -X ${PKG}/Version=${VERSION} -X ${PKG}/GitCommit=${VCS_REF} -X ${PKG}/BuildDate=${BUILD_DATE}"&& \
rm -fr vendor