Guide to build + run container with tensorflow for ARMv7l
Repo with tf2.3 on debian buster Link to Docker Hub
Versions
- v1.0 -> base variant
- v1.1 -> added packages to download modules.
- v1.2 -> more packages to download modules, HTTPS functionality.
- v1.3 -> jupyter fully functional.
- v1.4 -> SKlearn and pandas included.
Requires linux with docker installed.
I'am using wsl2 with Ubuntu with docker installed.
Run the following commands to setup envrionment to cross compile docker containers.
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx ls
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name mybuilder --driver docker-container --use
docker buildx inspect --bootstrap
docker buildx build --platform <Target_Platforms> -t <tag> . --pushdocker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64 -t 16fb/tf2.3:v1.4 . --push
<tag> = <namespace>/<name>:<version>
In this case its namedtf2.3in my personal16fbnamespace forversion 1.4
Replace16fb/tf2.3:v1.4with your respective image tag.
List of common platforms:
- linux/amd64
- linux/386
- linux/arm64
- linux/arm/v7
- linux/arm/v6
- linux/riscv64
- linux/ppc64le
- linux/s390x
docker run 16fb/tf2.3:v1.4
docker pull 16fb/tf2.3:v1.4
docker container run -it [docker_image] /bin/bashdocker container run -it 16fb/tf2.3:v1.4 /bin/bash
python3import tensorflow as tfprint(tf.___version__)
Runs Jupyter notebook server, exposing port 8899 on host machine, password auth is dependant on hash. How to compute Hash
export image="16fb/tf2.3:v1.4"
export Hash='<Hash here>'
export NOTEBOOKPORT=8899
docker run --env NOTEBOOKPORT=${NOTEBOOKPORT} --env Hash=${Hash} -p ${NOTEBOOKPORT}:${NOTEBOOKPORT}/tcp --rm -v $PWD:/data -w /data -u 0 --name JupyterNotebook -i $image /bin/bash << EOF
export PATH=$PATH:~/.local/bin
echo Running Jupyter Notebook Server:
jupyter notebook --NotebookApp.password='$Hash' --no-browser --port=$NOTEBOOKPORT --ip=0.0.0.0 --allow-root
EOF
Opens bash shell on container
docker exec -it JupyterNotebook /bin/bash
File size can be quite big.
Singularity pull docker uri.
singularity pull docker://16fb/tf2.3:v1.4
squashfstools is required by machine to convert docker into singularity containers
sudo apt-get install squashfs-tools
singularity shell 16fb/tf2.3:v1.4
Obtain writable(can install modules) version of container by using a sandbox: \
Build a Sandbox to enable writable version of container
sudo singularity build --sandbox <sand_box_name> <image_uri>sudo singularity build --sandbox tf2.3_sb_1.4 docker://16fb/tf2.3:v1.4
OR Convert SIF to Sandbox, be in same directory as SIF file (doesnt seem to work for me)
sudo singularity build --sandbox <sand_box_name> <sif_file_path>sudo singularity build --sandbox tf2.3_sb_1.4 tf2.3_v1.4.sif
Run as shell, mount mounts, allow writes so can install, Ensure you are root.
singularity shell --bind /mnt:/mnt --writable tf2.3_sb_1.4 /bin/bash
Export and Import docker image to file.
Save to tar file
docker save --output tf2.3_v1.4 16fb/tf2.3:v1.4
Load from tar file
docker load --input tf2.3_v1.4
fgervais who did something similar.
this blog that guides using buildx.