TensorFlow Docker container

If you want to do a manual pull of the container then you can, but the scripts can do it for you.

The TensorFlow Docker container is available from here
Pull with the appropriate tag for your needs. If building TensorFlow from git HEAD then use the tag latest-multipython but if building a specific release then you may need to use one for that release eg 2.16-multipython

Check out your source code on your development machine


cd ~/src git clone https://github.com/tensorflow/tensorflow.git cd tensorflow

The dockerfile used by the scripts is at tensorflow/tools/ci_build/Dockerfile.cpu.arm64 so you may want to take a quick look and edit if necessary.

Launch the docker container

With your current working directory still being the root of your TensorFlow source tree then you can launch the docker container with

CI_DOCKER_BUILD_EXTRA_PARAMS='--build-arg py_major_minor_version=3.11' CI_DOCKER_EXTRA_PARAMS='-it -d' ./tensorflow/tools/ci_build/ci_build.sh cpu.arm64 sleep infinity

This will launch the docker container and call it tf_ci.cpu.arm64

The above command chose Python 3.11. Currently you can use any one of 3.9, 3.10, 3.11 or 3.12.

The cpu.arm64 in the container name comes from the command above but also ties in to the Dockerfile name.

Enter the container

You can now get a command line in the container with

docker exec -it tf_ci.cpu.arm64 bash

You will enter as the superuser and will be in a directory /workspace that is mapped to your TensorFlow source tree.

Building as the superuser is not the best idea so the scripts will have created a new user in the container to match that of the one you were using when you entered the container and you can switch to this user with

sudo su - <username>

Where of course you replace the <username> part with your user name. Then you probably want to

cd /workspace

You will have sudo rights in the container and changes in the TensorFlow source tree you are in will happen in the host file system with your ID which should keep things sensible.

Updating the container

If you need to make changes to container eg install a version of clang other than clang-17 then now is the time to do it.

  1. Edit /etc/apt/sources.list and add any needed repo eg one for clang-18

  2. Run apt update

  3. Install the needed packages eg

    apt install clang-18 lld-18 libomp5-18 libomp-18-dev
  4. Make any needed changes to the source code eg edit tensorflow/tools/toolchains/cpus/aarch64/aarch64_compiler_configure.bzl to replace mention of llvm-17 with llvm-18

  5. If other repos need to be checked out use sudo to create a directory say in /tf and give yourself write access in it, then you can use that directory.

Building TensorFlow

Check to make sure that the file .bazelrc in the root of the TensorFlow tree contains the line below and if not then add it at the end.

import /usertools/aarch64_clang.bazelrc

You may also wish to use sudo to edit the file /usertools/aarch64_clang.bazelrc and remove or comment out the line 46 to prevent an annoying error warning in the build.


In the configure step below pay attention to the path suggestions offered and make any changes needed.