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
eg
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.
Edit
/etc/apt/sources.list
and add any needed repo eg one for clang-18Run
apt update
Install the needed packages eg
apt install clang-18 lld-18 libomp5-18 libomp-18-dev
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-18If 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.
build --profile=/tf/pkg/profile.json.gz
Â
In the configure step below pay attention to the path suggestions offered and make any changes needed.
cd /workspace
./configure
bazel build --config=mkl_aarch64_threadpool --copt=-flax-vector-conversions --define=tf_api_version=2 --verbose_failures -- //tensorflow/tools/pip_package:wheel
Or
bazel test --config=mkl_aarch64_threadpool --copt=-flax-vector-conversions --test_env=TF_ENABLE_ONEDNN_OPTS=1 --test_env=TF2_BEHAVIOR=1 --define=tf_api_version=2 --test_lang_filters=py,cc --test_size_filters=small,medium --test_output=errors --verbose_failures=true --test_keep_going --notest_verbose_timeout_warnings --action_env=PYTHON_BIN_PATH=/usr/local/bin/python3 --action_env=PYTHON_LIB_PATH=/usr/local/lib/python3.11/dist-packages --test_env=PORTSERVER_ADDRESS=@unittest-portserver --build_tag_filters=-no_oss,-oss_excluded,-oss_serial,-v1only,-benchmark-test,-no_aarch64,-gpu,-tpu,-no_oss_py39,-no_oss_py310 --test_tag_filters=-no_oss,-oss_excluded,-oss_serial,-v1only,-benchmark-test,-no_aarch64,-gpu,-tpu,-no_oss_py39,-no_oss_py310 --local_test_jobs=64 --build_tests_only -- //tensorflow/... -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/core/tpu/... -//tensorflow/go/... -//tensorflow/java/... -//tensorflow/python/integration_testing/... -//tensorflow/tools/toolchains/... -//tensorflow/lite/... -//tensorflow/core/kernels/image:resize_bicubic_op_test