h5py python causes TensorFlow installation error for Jetson Nano

After forcing the Jetson OS (based on the ubuntu 18.04) to have Python 3.8 running. After having the JetPack 4.6.3 installed in the Jetson Nano Jetson OS.

When attempting to install TensorFlow 2+ manually in the Jetson Nano based on Official TensorFlow for Jetson Nano! – Jetson & Embedded Systems / Jetson Nano – NVIDIA Developer Forums

Running the installation in Jetson Nano

Or running the pip3 install command:

sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v46 tensorflow

After a long time installing all the dependency for TensorFlow. A dreaded error message will occur.

ERROR: Failed to build installable wheels for some pyproject.toml based projects (h5py)

ERROR: Failed to build installable wheels for some pyproject.toml based projects (h5py)

To understand the error, scroll up to read what are the error.

The first error message scrolling up suggest the version of hd5 are not supported.

Loading library to get build settings and version: /usr/lib/aarch64-linux-gnu/hdf5/serial/libhdf5.so the details

Scroll higher, the error was triggered when pip is building the h5py dependency/library.

h5py fail, it is a dependency for tensorflow

Hence, forming the problem statement, h5py library for Python 3.8 cannot be installed due to the binary hdf5 of Jetson OS is version 1.10.0.

First approach will be updating the Jetson OS using apt-get to update the Jetson OS hdf5 library to at least version 1.10.0

First attempt used based on command:

sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev
The hdf5 library is already up to date

First attempt does not work, as minor version was not added to the repositories of dated Jetson OS (based on Ubuntu 18.04).

Second attempt, build the hd5 python library via source. Based on idea offered at Installation — h5py 3.13.0 documentation

Following the h5py documentation
Continue with the documentation, didn’t bothered setting up git correctly but it still works
Typo error but not the reason of build failure
Error suggested that numpy was not install into the Python 3.8
Install numpy

After numpy is installed, proceed to build the h5py, but encountered a different error.

New error, not old error means progress
Python.h were not found

The second attempt, the error encounter suggesting that the gcc compiler was not able to find header file, the Python.h during its compilation. Hence error.

After taking some time to research, installing python without the development tool kit will not able to help compilation due to missing header.

To fix this error, install the proper development library into Jetson OS.

sudo apt install libpython3.8-dev
Recompiling immediately after installation of the Python 3.8 development library, and h5py compiled and created
H5PY_SETUP_REQUIRES=0 pip3 install . --no-deps --no-build-isolation

Lets rerun the installation attempt to reinstall the TensorFlow.

sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v46 tensorflow
h5py which is manually compiled are detected and accepted by pip3
TensorFlow installation successful

Real test to validate TensorFlow successful installation works.

It works

And installing TensorFlow on dated Jetson Nano for the Jetson OS is challenging. It will help if a person has knowledge of Ubuntu, Python library management. The part that was left out was how to install Python 3.8.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.