From c838f4e2a28d1e8910bd5110634db6fdbdd87a47 Mon Sep 17 00:00:00 2001 From: Christoph Berganski Date: Sun, 28 Jan 2024 16:35:34 +0100 Subject: [PATCH 1/4] Disable interactive docker run This needs to be properly refactored and probably be exposed to the outside so the user is in control. Maybe default to interactive runs while introducing some flag to turn this off? --- run-docker.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index e732492728..348aebc9e3 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -137,7 +137,7 @@ elif [ "$1" = "build_custom" ]; then BUILD_CUSTOM_DIR=$(readlink -f "$2") FLOW_NAME=${3:-build} FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR:$BUILD_CUSTOM_DIR -w $BUILD_CUSTOM_DIR " - DOCKER_INTERACTIVE="-it" +# DOCKER_INTERACTIVE="-it" #FINN_HOST_BUILD_DIR=$BUILD_DATAFLOW_DIR/build gecho "Running build_custom: $BUILD_CUSTOM_DIR/$FLOW_NAME.py" DOCKER_CMD="python -mpdb -cc -cq $FLOW_NAME.py" @@ -178,7 +178,11 @@ gecho "Using default PYNQ board $PYNQ_BOARD" # Ensure git-based deps are checked out at correct commit if [ "$FINN_SKIP_DEP_REPOS" = "0" ]; then + # Need to ensure this is done within the finn/ root folder: + OLD_PWD=$(pwd) + cd $SCRIPTPATH ./fetch-repos.sh + cd $OLD_PWD fi # Build the FINN Docker image @@ -192,8 +196,9 @@ fi # Launch container with current directory mounted # important to pass the --init flag here for correct Vivado operation, see: # https://stackoverflow.com/questions/55733058/vivado-synthesis-hangs-in-docker-container-spawned-by-jenkins -DOCKER_BASE="docker run -t --rm $DOCKER_INTERACTIVE --tty --init --hostname $DOCKER_INST_NAME " -DOCKER_EXEC="-e SHELL=/bin/bash " +DOCKER_EXEC="docker run --rm $DOCKER_INTERACTIVE --init " # --tty --init " +DOCKER_EXEC+="--hostname $DOCKER_INST_NAME " +DOCKER_EXEC+="-e SHELL=/bin/bash " DOCKER_EXEC+="-w $SCRIPTPATH " DOCKER_EXEC+="-v $SCRIPTPATH:$SCRIPTPATH " DOCKER_EXEC+="-v $FINN_HOST_BUILD_DIR:$FINN_HOST_BUILD_DIR " From d502852fef672d89541113f05ca24197bccbb442 Mon Sep 17 00:00:00 2001 From: Christoph Berganski Date: Tue, 7 May 2024 14:17:46 +0200 Subject: [PATCH 2/4] Fix broken DOCKER_BASE command line --- run-docker.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index 348aebc9e3..395aed1cbb 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -196,9 +196,8 @@ fi # Launch container with current directory mounted # important to pass the --init flag here for correct Vivado operation, see: # https://stackoverflow.com/questions/55733058/vivado-synthesis-hangs-in-docker-container-spawned-by-jenkins -DOCKER_EXEC="docker run --rm $DOCKER_INTERACTIVE --init " # --tty --init " -DOCKER_EXEC+="--hostname $DOCKER_INST_NAME " -DOCKER_EXEC+="-e SHELL=/bin/bash " +DOCKER_BASE="docker run --rm $DOCKER_INTERACTIVE --init --hostname $DOCKER_INST_NAME " +DOCKER_EXEC="-e SHELL=/bin/bash " DOCKER_EXEC+="-w $SCRIPTPATH " DOCKER_EXEC+="-v $SCRIPTPATH:$SCRIPTPATH " DOCKER_EXEC+="-v $FINN_HOST_BUILD_DIR:$FINN_HOST_BUILD_DIR " From 7467d276e79cd774ff61e0bfe33ac1129ce48b97 Mon Sep 17 00:00:00 2001 From: Christoph Berganski Date: Wed, 29 Jan 2025 13:19:01 +0100 Subject: [PATCH 3/4] [Docker] Add and refactor defaults for DOCKER_INTERACTIVE flag Tests, notebooks and build flows now default to non-interactive docker run while while the container-only option defaults to the interactive bash prompt just as before. --- run-docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index ba6cc4c973..5cd9a4399c 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -103,8 +103,8 @@ SCRIPTPATH=$(dirname "$SCRIPT") : ${FINN_SKIP_XRT_DOWNLOAD=""} : ${FINN_XRT_PATH=""} : ${FINN_DOCKER_NO_CACHE="0"} - -DOCKER_INTERACTIVE="" +# Default to non-interactive runs, set DOCKER_INTERACTIVE="-it" +: "${DOCKER_INTERACTIVE=""}" # Catch FINN_DOCKER_EXTRA options being passed in without a trailing space FINN_DOCKER_EXTRA+=" " @@ -132,7 +132,6 @@ elif [ "$1" = "notebook" ]; then elif [ "$1" = "build_dataflow" ]; then BUILD_DATAFLOW_DIR=$(readlink -f "$2") FINN_DOCKER_EXTRA+="-v $BUILD_DATAFLOW_DIR:$BUILD_DATAFLOW_DIR " - DOCKER_INTERACTIVE="-it" #FINN_HOST_BUILD_DIR=$BUILD_DATAFLOW_DIR/build gecho "Running build_dataflow for folder $BUILD_DATAFLOW_DIR" DOCKER_CMD="build_dataflow $BUILD_DATAFLOW_DIR" @@ -140,13 +139,14 @@ elif [ "$1" = "build_custom" ]; then BUILD_CUSTOM_DIR=$(readlink -f "$2") FLOW_NAME=${3:-build} FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR:$BUILD_CUSTOM_DIR -w $BUILD_CUSTOM_DIR " -# DOCKER_INTERACTIVE="-it" #FINN_HOST_BUILD_DIR=$BUILD_DATAFLOW_DIR/build gecho "Running build_custom: $BUILD_CUSTOM_DIR/$FLOW_NAME.py" DOCKER_CMD="python -mpdb -cc -cq $FLOW_NAME.py ${@:4}" elif [ -z "$1" ]; then gecho "Running container only" DOCKER_CMD="bash" + # Overwrite the default, container only should always be interactive as it + # drops us into a bash prompt... DOCKER_INTERACTIVE="-it" else gecho "Running container with passed arguments" From 1cf9228ff85d02ca7bb3abeb241c829fc1075827 Mon Sep 17 00:00:00 2001 From: Christoph Berganski Date: Wed, 29 Jan 2025 14:38:22 +0100 Subject: [PATCH 4/4] [Docker] Always default to DOCKER_INTERACTIVE="-it" --- run-docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index 5cd9a4399c..0a91ebc422 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -103,8 +103,8 @@ SCRIPTPATH=$(dirname "$SCRIPT") : ${FINN_SKIP_XRT_DOWNLOAD=""} : ${FINN_XRT_PATH=""} : ${FINN_DOCKER_NO_CACHE="0"} -# Default to non-interactive runs, set DOCKER_INTERACTIVE="-it" -: "${DOCKER_INTERACTIVE=""}" +# Default to interactive runs, for non-interactive set DOCKER_INTERACTIVE="" +: "${DOCKER_INTERACTIVE="-it"}" # Catch FINN_DOCKER_EXTRA options being passed in without a trailing space FINN_DOCKER_EXTRA+=" " @@ -145,8 +145,8 @@ elif [ "$1" = "build_custom" ]; then elif [ -z "$1" ]; then gecho "Running container only" DOCKER_CMD="bash" - # Overwrite the default, container only should always be interactive as it - # drops us into a bash prompt... + # Overwrite: container only should always be interactive as it drops us into + # a bash prompt... DOCKER_INTERACTIVE="-it" else gecho "Running container with passed arguments"