|
| 1 | +FROM ubuntu:18.04 |
| 2 | + |
| 3 | +# Environment variables and args |
| 4 | + |
| 5 | +ARG NOTEBOOK_USER=root |
| 6 | +ARG NOTEBOOK_UID=1000 |
| 7 | +ENV USER ${NOTEBOOK_USER} |
| 8 | +ENV NOTEBOOK_UID ${NOTEBOOK_UID} |
| 9 | +ENV HOME /home/${NOTEBOOK_USER} |
| 10 | + |
| 11 | +WORKDIR ${HOME} |
| 12 | + |
| 13 | +USER root |
| 14 | +# Downloads the package lists from the repositories and "updates" them |
| 15 | +# to get information on the newest versions of packages and their dependencies. |
| 16 | +RUN apt-get update |
| 17 | + |
| 18 | +# Install 'curl': Command line tool that allows you to transfer data from or to a remote server. |
| 19 | +# With curl, you can download or upload data using HTTP, HTTPS, SCP, SFTP, and FTP. |
| 20 | +RUN apt-get install -y curl |
| 21 | + |
| 22 | + |
| 23 | +### Building image START |
| 24 | + |
| 25 | +# workaround bug https://grigorkh.medium.com/fix-tzdata-hangs-docker-image-build-cdb52cc3360d |
| 26 | +ENV TZ=Asia/Dubai |
| 27 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
| 28 | + |
| 29 | +RUN apt update |
| 30 | +RUN apt install -y tzdata |
| 31 | + |
| 32 | + |
| 33 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 34 | + build-essential \ |
| 35 | + cmake \ |
| 36 | + git \ |
| 37 | + wget \ |
| 38 | + python3.8-dev \ |
| 39 | + python3-skimage \ |
| 40 | + python3-opencv \ |
| 41 | + python3-pip \ |
| 42 | + #required by pandas |
| 43 | + libgfortran5 \ |
| 44 | + libopenblas-dev \ |
| 45 | + libatlas-base-dev \ |
| 46 | + libboost-python1.65-dev \ |
| 47 | + libboost-all-dev \ |
| 48 | + libgflags-dev \ |
| 49 | + #Directly incorporate Google glog projects from Github instead of consume it. |
| 50 | + #See https://github.com/google/glog#incorporating-glog-into-a-cmake-project |
| 51 | + #Not install google glog into env and incorporate into cmake build directly. |
| 52 | + libgoogle-glog-dev \ |
| 53 | + libhdf5-serial-dev \ |
| 54 | + libleveldb-dev \ |
| 55 | + liblmdb-dev \ |
| 56 | + libopencv-dev \ |
| 57 | + libprotobuf-dev \ |
| 58 | + libsnappy-dev \ |
| 59 | + libmatio-dev \ |
| 60 | + protobuf-compiler && \ |
| 61 | + rm -rf /var/lib/apt/lists/* |
| 62 | + |
| 63 | +ENV CAFFE_ROOT=/opt/caffe |
| 64 | +WORKDIR $CAFFE_ROOT |
| 65 | + |
| 66 | +#update cmake version from default 3.10 to latest |
| 67 | +RUN pip3 install --upgrade pip && \ |
| 68 | + pip3 install --upgrade cmake && \ |
| 69 | + cmake --version |
| 70 | + |
| 71 | +#Hack for libboost-python binding when both python2 and python3 present. |
| 72 | +RUN cd /usr/lib/x86_64-linux-gnu && \ |
| 73 | + unlink libboost_python.so && \ |
| 74 | + unlink libboost_python.a && \ |
| 75 | + ln -s libboost_python-py36.so libboost_python.so && \ |
| 76 | + ln -s libboost_python-py36.a libboost_python.a && \ |
| 77 | + cd - |
| 78 | + |
| 79 | +#Start Building |
| 80 | +RUN git clone https://github.com/foss-for-synopsys-dwc-arc-processors/synopsys-caffe.git . && \ |
| 81 | + pip3 install --upgrade pip && \ |
| 82 | + cd python && for req in $(cat requirements.txt) pydot; do pip3 install $req; done && cd .. && \ |
| 83 | + mkdir build && cd build && \ |
| 84 | + cmake -DCPU_ONLY=1 .. && \ |
| 85 | + make -j"$(nproc)" && \ |
| 86 | + make runtest |
| 87 | + |
| 88 | +ENV PYCAFFE_ROOT $CAFFE_ROOT/python |
| 89 | +ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH |
| 90 | +ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH |
| 91 | +RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig |
| 92 | + |
| 93 | +### Building image END |
| 94 | + |
| 95 | + |
| 96 | +# install the notebook package |
| 97 | +RUN pip3 install notebook jupyterlab |
| 98 | + |
| 99 | +# Copy notebooks |
| 100 | + |
| 101 | +COPY ./ ${HOME}/Notebooks/ |
| 102 | + |
| 103 | +RUN chown -R ${NOTEBOOK_UID} ${HOME} |
| 104 | +USER ${USER} |
| 105 | + |
| 106 | + |
| 107 | +RUN echo "$PATH" |
| 108 | + |
| 109 | +### hack for bug inside Notebooks |
| 110 | +RUN pip3 uninstall -y scipy && pip3 install scipy |
| 111 | +RUN pip3 uninstall -y pyyaml && python3 -m pip install PyYAML |
| 112 | + |
| 113 | +# Set root to Notebooks |
| 114 | +WORKDIR ${HOME}/Notebooks/ |
0 commit comments