This wiki explains how to build Tensorflow 1.13.1 for ARMv8 platform (aarch64 arm64)
Start a1.4xlarge instance with Ubuntu 16.04 OS and 64GB disk
sudo apt update
sudo apt upgrade
sudo reboot
sudo apt install build-essential
sudo apt install python3 python3-dev
sudo apt install pkg-config zip zlib1g-dev unzip curl tmux wget vim git htop
sudo apt install openjdk-8-jdk
sudo apt install liblapack3 libblas3 libhdf5-dev
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
sudo pip3 install six mock numpy grpcio
sudo pip3 install h5py==2.10.0
sudo pip3 install keras_applications --no-deps
sudo pip3 install keras_preprocessing --no-deps
wget https://github.com/bazelbuild/bazel/releases/download/0.19.2/bazel-0.19.2-dist.zip
mkdir bazel-0.19.2
unzip bazel-0.19.2-dist.zip -d bazel-0.19.2
cd bazel-0.19.2
# open tmux session
tmux
./compile.sh
# Copy bazel to $PATH
sudo cp output/bazel /usr/local/bin/
cd ..
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout v1.13.1
# run configure. It will ask several questions
# change python path to /usr/bin/python3
# hit enter for all other questions (default settings)
./configure
# Monolithic option will produce 90 MB wheel file. Without monolithic - 60MB
# --config=monolithic
# Make sure you are still in tmux session. Build will take about 1.5 hours
bazel build -c opt \
--copt=-O3 \
--copt=-std=c++11 \
--copt=-funsafe-math-optimizations \
--copt=-ftree-vectorize \
--copt=-fomit-frame-pointer \
--copt=-DRASPBERRY_PI \
--host_copt=-DRASPBERRY_PI \
--verbose_failures \
--config=noaws \
--config=nogcp \
--config=nohdfs \
--config=noignite \
--config=nokafka \
--config=nonccl \
//tensorflow/tools/pip_package:build_pip_package
# Build a universal wheel.
BDIST_OPTS="--universal" bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/tensorflow_pkg
sudo pip3 install ~/tensorflow_pkg/tensorflow-1.13.1-cp35-cp35m-linux_aarch64.whl
import tensorflow as tf
tf.__version__
tf.__path__
a = tf.placeholder(tf.float32, shape=[2, 2], name="input1")
b = tf.placeholder(tf.float32, shape=[2, 2], name="input2")
ab = tf.matmul(a, b, name="output")
inp1 = [[4., 7.], [2., 6.]]
inp2 = [[0.6, -0.7], [-0.2, 0.4]]
with tf.Session() as sess:
res = sess.run(ab, feed_dict={a: inp1, b: inp2})
print(res)
https://www.tensorflow.org/install/source https://collaborate.linaro.org/display/BDTS/Building+and+Installing+Tensorflow+on+AArch64 https://github.com/lhelontra/tensorflow-on-arm/releases
I followed your instruction but it hang the system after running for about 2 hours :(, 4gb ram and 1gb swap are full! I tried to build tensorflow2.3.0 with bazel on aarch64 linux (raspberry 4 - python3.8). Could you please help me any solution that I can try!