Skip to content

Commit 35dc446

Browse files
authored
Merge pull request #375 from puneetmatharu/patch-cleanup-for-pytorch-and-tensorflow
Patch clean-up for PyTorch and TensorFlow
2 parents ab5d9cf + 0560075 commit 35dc446

3 files changed

Lines changed: 61 additions & 6 deletions

File tree

ML-Frameworks/pytorch-aarch64/build.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,34 @@ if [ -f .torch_build_container_id ] || [ -f .torch_ao_build_container_id ] || \
4545

4646
# Wipe old build artefacts
4747
if [[ $* == *--fresh* ]]; then
48-
if [ -f .torch_build_container_id ]; then rm -f .torch_build_container_id; fi
49-
if [ -f .torch_ao_build_container_id ]; then rm -f .torch_ao_build_container_id; fi
48+
# Make sure we can wipe directories created with root privileges in Docker
49+
if [ -f .torch_build_container_id ]; then
50+
TORCH_BUILD_CONTAINER=$(cat .torch_build_container_id)
51+
if [ ! -z "$(docker ps -a --no-trunc | grep $TORCH_BUILD_CONTAINER)" ]; then
52+
# Change permissions from root
53+
docker exec $TORCH_BUILD_CONTAINER chown -R $(id -u):$(id -g) /artifacts 2>/dev/null || true
54+
docker exec $TORCH_BUILD_CONTAINER chown -R $(id -u):$(id -g) /ComputeLibrary 2>/dev/null || true
55+
docker exec $TORCH_BUILD_CONTAINER chown -R $(id -u):$(id -g) /pytorch 2>/dev/null || true
56+
57+
# Wipe old container
58+
docker rm -f $TORCH_BUILD_CONTAINER 2>/dev/null || true
59+
fi
60+
rm -f .torch_build_container_id
61+
fi
62+
63+
# Make sure we can wipe directories created with root privileges in Docker
64+
if [ -f .torch_ao_build_container_id ]; then
65+
TORCH_AO_BUILD_CONTAINER=$(cat .torch_ao_build_container_id)
66+
if [ ! -z "$(docker ps -a --no-trunc | grep $TORCH_AO_BUILD_CONTAINER)" ]; then
67+
docker exec $TORCH_AO_BUILD_CONTAINER chown -R $(id -u):$(id -g) /ao
68+
69+
# Wipe old container
70+
docker rm -f $TORCH_AO_BUILD_CONTAINER 2>/dev/null || true
71+
fi
72+
rm -f .torch_ao_build_container_id
73+
fi
74+
75+
# Wipe the other directories; we should have the privileges now
5076
if [ -d ao ]; then rm -rf ao; fi
5177
if [ -d ComputeLibrary ]; then rm -rf ComputeLibrary; fi
5278
if [ -d pytorch ]; then rm -rf pytorch; fi

ML-Frameworks/tensorflow-aarch64/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ https://github.com/ARM-software/Tool-Solutions/tree/r25.09
2525
### Changed
2626
- Updates TensorFLow hash to 6aa8fd07270293b918255af5988aef45b844c5b4 # from nightly, September 22nd
2727
- Updates `dockerize.sh` build to use BuildKit (to add extra build contexts)
28+
- Change of flag name in `./build.sh` from `--force` to `--fresh`
2829

2930
### Removed
3031
- Removed previous patch updating oneDNN and Compute Library that has been merged upstream

ML-Frameworks/tensorflow-aarch64/build.sh

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,41 @@ exec &> >(tee -a $build_log)
2525

2626
# # Bail out if sources are already there
2727
if [ -d tensorflow ] ; then
28-
echo "You appear to have sources already" \
28+
printf "\n\n%s\n%s\n%s\n\n\n" \
29+
"You appear to have artefacts from a previous build lying around." \
30+
"Check for the following:" \
31+
" - tensorflow"
2932

30-
if ! ([[ $* == *--force* ]] || [[ $* == *--use-existing-sources* ]]) ; then
31-
echo "rerun with --force to overwrite sources or with" \
32-
"--use-existing-sources to build your existing sources." 1>&2
33+
if ! ([[ $* == *--fresh* ]] || [[ $* == *--use-existing-sources* ]]) ; then
34+
printf "\n\n%s\n%s\n%s\n\n\n" \
35+
"Rerun with one of the following options:" \
36+
" - '--fresh': wipe the pre-existing sources and do a fresh build" \
37+
" - '--use-existing-sources': reuse the sources as is" 1>&2
3338
exit 1
3439
fi
40+
41+
# Wipe old build artefacts
42+
if [[ $* == *--fresh* ]]; then
43+
if [ -d tensorflow ]; then
44+
# Change permissions for folders created as root in docker
45+
if [ -d tensorflow/build_output ]; then
46+
if [ ! -z "$(docker ps -a --no-trunc | grep tf)" ]; then
47+
docker exec tf chown -R $(id -u):$(id -g) build_output 2>/dev/null || true
48+
else
49+
printf "\n\n%s\n%s\n%s\n\n\n" \
50+
"Unable to locate docker container 'tf'. You may need to" \
51+
"rerun this script with sudo privileges to make sure everything" \
52+
"has been properly wiped."
53+
fi
54+
fi
55+
56+
# Wipe the container. Adapted from: tensorflow/ci/official/utilities/cleanup_docker.sh
57+
docker rm -f tf 2>/dev/null || true
58+
59+
# Wipe the folder
60+
rm -rf tensorflow
61+
fi
62+
fi
3563
fi
3664

3765
if ! [[ $* == *--use-existing-sources* ]]; then

0 commit comments

Comments
 (0)