Skip to content
Snippets Groups Projects
Commit 0c51fe0c authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[Docker] create Dockerfile.finn_dev, run from run-docker.sh

parent aff4137e
No related branches found
No related tags found
No related merge requests found
...@@ -29,27 +29,52 @@ ...@@ -29,27 +29,52 @@
FROM pytorch/pytorch:1.1.0-cuda10.0-cudnn7.5-devel FROM pytorch/pytorch:1.1.0-cuda10.0-cudnn7.5-devel
MAINTAINER Yaman Umuroglu <yamanu@xilinx.com> MAINTAINER Yaman Umuroglu <yamanu@xilinx.com>
ARG PYTHON_VERSION=3.6 ARG PYTHON_VERSION=3.6
ARG GID
ARG GNAME
ARG UNAME
ARG UID
ARG PASSWD
ARG JUPYTER_PORT
ARG NETRON_PORT
EXPOSE $JUPYTER_PORT
EXPOSE $NETRON_PORT
WORKDIR /workspace WORKDIR /workspace
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y build-essential libglib2.0-0 libsm6 libxext6 libxrender-dev
RUN apt-get install verilator
RUN apt-get install nano
RUN apt-get -y install sshpass
RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
COPY requirements.txt . COPY requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
RUN rm requirements.txt RUN rm requirements.txt
RUN apt update; apt install nano
RUN pip install jupyter RUN pip install jupyter
RUN pip install netron RUN pip install netron
RUN pip install matplotlib RUN pip install matplotlib
RUN pip install pytest-dependency RUN pip install pytest-dependency
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y build-essential libglib2.0-0 libsm6 libxext6 libxrender-dev
RUN apt install verilator
RUN apt-get -y install sshpass
RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
RUN pip install sphinx RUN pip install sphinx
RUN pip install sphinx_rtd_theme RUN pip install sphinx_rtd_theme
# cloning dependency repos # copy entrypoint script
COPY docker/finn_entrypoint.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/finn_entrypoint.sh
# switch user
RUN groupadd -g $GID $GNAME
RUN useradd -M -u $UID $UNAME -g $GNAME
RUN usermod -aG sudo $UNAME
RUN echo "$UNAME:$PASSWD" | chpasswd
RUN echo "root:$PASSWD" | chpasswd
RUN ln -s /workspace /home/$UNAME
RUN chown -R $UNAME:$GNAME /home/$UNAME
USER $UNAME
# cloning dependency repos (as user)
# Brevitas # Brevitas
RUN git clone --branch feature/finn_onnx_export https://github.com/Xilinx/brevitas.git /workspace/brevitas RUN git clone --branch feature/finn_onnx_export https://github.com/Xilinx/brevitas.git /workspace/brevitas
RUN git -C /workspace/brevitas checkout 215cf44c76d562339fca368c8c3afee3110033e8 RUN git -C /workspace/brevitas checkout 215cf44c76d562339fca368c8c3afee3110033e8
...@@ -77,33 +102,14 @@ RUN git -C /workspace/PYNQ-HelloWorld checkout db7e418767ce2a8e08fe732ddb3aa56ee ...@@ -77,33 +102,14 @@ RUN git -C /workspace/PYNQ-HelloWorld checkout db7e418767ce2a8e08fe732ddb3aa56ee
# Note that we expect the cloned finn directory on the host to be # Note that we expect the cloned finn directory on the host to be
# mounted on /workspace/finn -- see run-docker.sh for an example # mounted on /workspace/finn -- see run-docker.sh for an example
# of how to do this. # of how to do this.
# This branch assumes the same for brevitas and brevitas_cnv_lfc for easier
# co-development.
ENV PYTHONPATH "${PYTHONPATH}:/workspace/finn/src" ENV PYTHONPATH "${PYTHONPATH}:/workspace/finn/src"
ENV PYTHONPATH "${PYTHONPATH}:/workspace/brevitas_cnv_lfc/training_scripts" ENV PYTHONPATH "${PYTHONPATH}:/workspace/brevitas_cnv_lfc/training_scripts"
ENV PYTHONPATH "${PYTHONPATH}:/workspace/brevitas" ENV PYTHONPATH "${PYTHONPATH}:/workspace/brevitas"
ENV PYTHONPATH "${PYTHONPATH}:/workspace/pyverilator" ENV PYTHONPATH "${PYTHONPATH}:/workspace/pyverilator"
ENV PYNQSHELL_PATH "/workspace/PYNQ-HelloWorld/boards" ENV PYNQSHELL_PATH "/workspace/PYNQ-HelloWorld/boards"
ARG GID
ARG GNAME
ARG UNAME
ARG UID
ARG PASSWD
ARG JUPYTER_PORT
ARG NETRON_PORT
RUN groupadd -g $GID $GNAME
RUN useradd -M -u $UID $UNAME -g $GNAME
RUN usermod -aG sudo $UNAME
RUN echo "$UNAME:$PASSWD" | chpasswd
RUN echo "root:$PASSWD" | chpasswd
RUN ln -s /workspace /home/$UNAME
RUN chown -R $UNAME:$GNAME /home/$UNAME
USER $UNAME
RUN echo "source \$VIVADO_PATH/settings64.sh" >> /home/$UNAME/.bashrc
RUN echo "PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '" >> /home/$UNAME/.bashrc
EXPOSE $JUPYTER_PORT
EXPOSE $NETRON_PORT
WORKDIR /home/$UNAME/finn WORKDIR /home/$UNAME/finn
RUN echo "PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '" >> /home/$UNAME/.bashrc
ENTRYPOINT ["finn_entrypoint.sh"]
CMD ["bash"]
...@@ -44,10 +44,10 @@ DOCKER_PASSWD="finn" ...@@ -44,10 +44,10 @@ DOCKER_PASSWD="finn"
# generate a random number per-run to allow multiple # generate a random number per-run to allow multiple
# containers from the same user # containers from the same user
DOCKER_RND=$(shuf -i0-32768 -n1) DOCKER_RND=$(shuf -i0-32768 -n1)
DOCKER_TAG="finn_${DOCKER_UNAME}" DOCKER_TAG="finn_dev_${DOCKER_UNAME}"
# uncomment to run multiple instances with different names # uncomment to run multiple instances with different names
# DOCKER_INST_NAME="finn_${DOCKER_UNAME}_${DOCKER_RND}" # DOCKER_INST_NAME="finn_${DOCKER_UNAME}_${DOCKER_RND}"
DOCKER_INST_NAME="finn_${DOCKER_UNAME}" DOCKER_INST_NAME="finn_dev_${DOCKER_UNAME}"
# ensure Docker tag and inst. name are all lowercase # ensure Docker tag and inst. name are all lowercase
DOCKER_TAG=$(echo "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]') DOCKER_TAG=$(echo "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]')
DOCKER_INST_NAME=$(echo "$DOCKER_INST_NAME" | tr '[:upper:]' '[:lower:]') DOCKER_INST_NAME=$(echo "$DOCKER_INST_NAME" | tr '[:upper:]' '[:lower:]')
...@@ -59,6 +59,7 @@ DOCKER_INST_NAME=$(echo "$DOCKER_INST_NAME" | tr '[:upper:]' '[:lower:]') ...@@ -59,6 +59,7 @@ DOCKER_INST_NAME=$(echo "$DOCKER_INST_NAME" | tr '[:upper:]' '[:lower:]')
: ${PYNQ_PASSWORD="xilinx"} : ${PYNQ_PASSWORD="xilinx"}
: ${PYNQ_BOARD="Pynq-Z1"} : ${PYNQ_BOARD="Pynq-Z1"}
: ${PYNQ_TARGET_DIR="/home/xilinx/$DOCKER_INST_NAME"} : ${PYNQ_TARGET_DIR="/home/xilinx/$DOCKER_INST_NAME"}
: ${NUM_DEFAULT_WORKERS=1}
# Absolute path to this script, e.g. /home/user/bin/foo.sh # Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(readlink -f "$0") SCRIPT=$(readlink -f "$0")
...@@ -83,17 +84,17 @@ echo "Using default PYNQ board $PYNQ_BOARD" ...@@ -83,17 +84,17 @@ echo "Using default PYNQ board $PYNQ_BOARD"
if [ "$1" = "test" ]; then if [ "$1" = "test" ]; then
echo "Running test suite" echo "Running test suite"
DOCKER_CMD="source ~/.bashrc; python setup.py test" DOCKER_CMD="python setup.py test"
elif [ "$1" = "notebook" ]; then elif [ "$1" = "notebook" ]; then
echo "Running Jupyter notebook server" echo "Running Jupyter notebook server"
DOCKER_CMD="source ~/.bashrc; jupyter notebook --ip=0.0.0.0 --port $JUPYTER_PORT notebooks" DOCKER_CMD="jupyter notebook --ip=0.0.0.0 --port $JUPYTER_PORT notebooks"
else else
echo "Running container only" echo "Running container only"
DOCKER_CMD="bash" DOCKER_CMD="bash"
fi fi
# Build the FINN Docker image # Build the FINN Docker image
docker build --tag=$DOCKER_TAG \ docker build -f docker/Dockerfile.finn_dev --tag=$DOCKER_TAG \
--build-arg GID=$DOCKER_GID \ --build-arg GID=$DOCKER_GID \
--build-arg GNAME=$DOCKER_GNAME \ --build-arg GNAME=$DOCKER_GNAME \
--build-arg UNAME=$DOCKER_UNAME \ --build-arg UNAME=$DOCKER_UNAME \
...@@ -119,6 +120,7 @@ docker run -t --rm --name $DOCKER_INST_NAME -it \ ...@@ -119,6 +120,7 @@ docker run -t --rm --name $DOCKER_INST_NAME -it \
-e PYNQ_USERNAME=$PYNQ_USERNAME \ -e PYNQ_USERNAME=$PYNQ_USERNAME \
-e PYNQ_PASSWORD=$PYNQ_PASSWORD \ -e PYNQ_PASSWORD=$PYNQ_PASSWORD \
-e PYNQ_TARGET_DIR=$PYNQ_TARGET_DIR \ -e PYNQ_TARGET_DIR=$PYNQ_TARGET_DIR \
-e NUM_DEFAULT_WORKERS=$NUM_DEFAULT_WORKERS \
-p $JUPYTER_PORT:$JUPYTER_PORT \ -p $JUPYTER_PORT:$JUPYTER_PORT \
-p $NETRON_PORT:$NETRON_PORT \ -p $NETRON_PORT:$NETRON_PORT \
$DOCKER_TAG bash -c "$DOCKER_CMD" $DOCKER_TAG $DOCKER_CMD
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment