Failed install numpy on jetpack 4.4

Description

I want to install tensorflow 1.15.2 from official whl file, and this need to install numpy package and then I installed these package:

$ sudo apt-get install -y libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
$ sudo pip3 install -U pip testresources setuptools
$sudo pip3 install -U numpy==1.16.1 future mock h5py keras_preprocessing keras_applications gast futures pybind11

but for installation numpy both version 1.16.1 and 1.18.x, I get this error:

ERROR: Command errored out with exit status 1:
 command: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmprbi4l_5d
     cwd: /tmp/pip-install-oql7xfwl/numpy
Complete output (158 lines):
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_mt19937.pyx
Processing numpy/random/_philox.pyx
Processing numpy/random/_generator.pyx
Processing numpy/random/_bounded_integers.pyx.in
Processing numpy/random/mtrand.pyx
Processing numpy/random/_sfc64.pyx
Processing numpy/random/_pcg64.pyx
Processing numpy/random/_common.pyx
Processing numpy/random/_bit_generator.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
customize UnixCCompiler
  libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/aarch64-linux-gnu']
  NOT AVAILABLE

blis_info:
  libraries blis not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/aarch64-linux-gnu']
  NOT AVAILABLE

openblas_info:
C compiler: aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

creating /tmp/tmp0fcwekj6/tmp
creating /tmp/tmp0fcwekj6/tmp/tmp0fcwekj6
compile options: '-c'
aarch64-linux-gnu-gcc: /tmp/tmp0fcwekj6/source.c
aarch64-linux-gnu-gcc -pthread /tmp/tmp0fcwekj6/tmp/tmp0fcwekj6/source.o -lopenblas -o /tmp/tmp0fcwekj6/a.out
  FOUND:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/lib/aarch64-linux-gnu']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

  FOUND:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/lib/aarch64-linux-gnu']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

non-existing path in 'numpy/distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
  libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/aarch64-linux-gnu']
  NOT AVAILABLE

openblas_lapack_info:
C compiler: aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

creating /tmp/tmpyqjqmx6n/tmp
creating /tmp/tmpyqjqmx6n/tmp/tmpyqjqmx6n
compile options: '-c'
aarch64-linux-gnu-gcc: /tmp/tmpyqjqmx6n/source.c
aarch64-linux-gnu-gcc -pthread /tmp/tmpyqjqmx6n/tmp/tmpyqjqmx6n/source.o -lopenblas -o /tmp/tmpyqjqmx6n/a.out
  FOUND:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/lib/aarch64-linux-gnu']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

  FOUND:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/lib/aarch64-linux-gnu']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

running dist_info
running build_src
build_src
building py_modules sources
creating build
creating build/src.linux-aarch64-3.6
creating build/src.linux-aarch64-3.6/numpy
creating build/src.linux-aarch64-3.6/numpy/distutils
building library "npymath" sources
creating build/src.linux-aarch64-3.6/numpy/core
creating build/src.linux-aarch64-3.6/numpy/core/src
creating build/src.linux-aarch64-3.6/numpy/core/src/npymath
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npymath/npy_math_internal.h
  adding 'build/src.linux-aarch64-3.6/numpy/core/src/npymath' to include_dirs.
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npymath/ieee754.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npymath/npy_math_complex.c
None - nothing done with h_files = ['build/src.linux-aarch64-3.6/numpy/core/src/npymath/npy_math_internal.h']
building library "npysort" sources
creating build/src.linux-aarch64-3.6/numpy/core/src/common
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/common/npy_sort.h
  adding 'build/src.linux-aarch64-3.6/numpy/core/src/common' to include_dirs.
creating build/src.linux-aarch64-3.6/numpy/core/src/npysort
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/quicksort.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/mergesort.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/timsort.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/heapsort.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/radixsort.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/common/npy_partition.h
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/selection.c
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/common/npy_binsearch.h
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/npysort/binsearch.c
None - nothing done with h_files = ['build/src.linux-aarch64-3.6/numpy/core/src/common/npy_sort.h', 'build/src.linux-aarch64-3.6/numpy/core/src/common/npy_partition.h', 'build/src.linux-aarch64-3.6/numpy/core/src/common/npy_binsearch.h']
building extension "numpy.core._multiarray_tests" sources
creating build/src.linux-aarch64-3.6/numpy/core/src/multiarray
conv_template:> build/src.linux-aarch64-3.6/numpy/core/src/multiarray/_multiarray_tests.c
building extension "numpy.core._multiarray_umath" sources
Running from numpy source directory.
setup.py:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
  run_build = parse_setuppy_commands()
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
    main()
  File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 158, in prepare_metadata_for_build_wheel
    self.run_setup()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 250, in run_setup
    self).run_setup(setup_script=setup_script)
  File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 143, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 488, in <module>
    setup_package()
  File "setup.py", line 480, in setup_package
    setup(**metadata)
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/core.py", line 171, in setup
    return old_setup(**new_attr)
  File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/dist_info.py", line 31, in run
    egg_info.run()
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/command/egg_info.py", line 26, in run
    self.run_command("build_src")
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/command/build_src.py", line 146, in run
    self.build_sources()
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/command/build_src.py", line 163, in build_sources
    self.build_extension_sources(ext)
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/command/build_src.py", line 320, in build_extension_sources
    sources = self.generate_sources(sources, ext)
  File "/tmp/pip-install-oql7xfwl/numpy/numpy/distutils/command/build_src.py", line 380, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 430, in generate_config_h
    moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
  File "numpy/core/setup.py", line 49, in check_types
    out = check_types(*a, **kw)
  File "numpy/core/setup.py", line 288, in check_types
    "install {0}-dev|{0}-devel.".format(python))
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmprbi4l_5d Check the logs for full command output.

Environment

TensorRT Version : 7.1.0 [Developer Preview]
GPU Type : Jetson Nano
Nvidia Driver Version : JetPack-4.4 DP (L4T R32.4.2)
CUDA Version : 10.2
CUDNN Version : 8.0.0 [Develop Preview]
Operating System + Version : Ubuntu 18.04, Linux kernel 4.9.140
Python Version (if applicable) : 3.6.9
Baremetal or Container (if container which image + tag) : Baremetal

Hi,

A similar issue can be found here:

Would you mind to install python3.6-dev to see if helps first?

sudo apt-get install python3.6-dev

Thanks.

Hello,

I’m using python3.6 but, failed to install numpy on jetpack 4.4
What am I suppose to do?
image
Thank you.

Hi, I’m having a similar problem with building numpy after trying to pip install it, but I’ve had already installed the python3.6-dev apt package. Any other suggiestion? Maybe try with an older numpy version? Anyone else with this problem?

Thank you.
Best regards,
Eduardo

Hi, Ive been digging a little on my issue, and I can confirm its not totalle related to OP’s problem.
The problem apparently has do to with h5py and any packages that has h5py as a dependency.
Basically when pip is installing h5py (pip3 install h5py) it tries to build numpy (maybe a specific version?) that refers to the xlocale.h header that is not found. This seems to be the root of all the other problems. Numpy itself can be installed from wheel with no problem (probably not being rebuilt but using precompiled wheels).

Ill try to finish to pin down the error and find a solution to this h5py and see if its standard issue on 4.4 or if I have something messed up on my installation. I will also try the same steps before and after the installation of suggested packages and updates after a fresh install.

Ill keep you posted.
Thank you.
Best regards.
Eduardo

@drakorg, Thanks so much,
If possible share your experience about steps installation for numpy.

Thanks.

Ok, I can confirm the issue.

Steps to reproduce:

  1. Flash a fresh image of JP 4.4.1 on an sd card.
  2. Boot configure everything (language, user, etc, basic stuff).
  3. do NOT install any suggested packages after fresh installation.
  4. sudo apt update
  5. sudo apt install curl # needed for the get-pip.sh bootstrap
  6. install pip3 via the bootstrap (I can point to it if you want, but it basically uses the get-pip.sh following the recommended method, instead of the apt package.
  7. pip3 install h5py # it fails because of missing Python.h
  8. sudo apt-get install python3.6-dev # it installs Python.h (amongst other things)
  9. pip3 install h5py # it now fails because of missing xlocale.h, when it tries to build numpy (???)

This may indeed be a problem of h5py, but since h5py is a dependency of many other packages, it would be nice if it worked. I will now try to look for a workaround, but the problem is just as described.

Hope it helps.
Thank you.
Eduardo

NOTES:

1.numpy is indeed installed by the time h5py tries to build it:

drakorg@jp441:~/workspace$ python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.13.3'
>>>
  1. xlocale.h is related to LLVM project, there are many (different) versions of this file laying around, but none of them is referenced in the build:

/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda/std/std/detail/libcxx/include/support/solaris/xlocale.h
/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda/std/std/detail/libcxx/include/support/newlib/xlocale.h
/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda/std/std/detail/libcxx/include/support/ibm/xlocale.h
/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda/std/std/detail/libcxx/include/support/musl/xlocale.h
/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda/std/std/detail/libcxx/include/support/fuchsia/xlocale.h

Ok, the problem persists even after installing all the suggested packages ubuntu greets you with after a fresh install.
Regards,
Eduardo

@drakorg, Thanks so much.

@neuezeal @drakorg I ran into the same issue with Jetpack 4.3. After intensive “googling”, the only solution for me was to use an older version of h5py (ver 2.9.0, numpy 1.13.3)

1 Like

Thanks a lot, I’ll try that right now.

I just found a reference to what appears to be the same issue: https://gitmemory.com/issue/h5py/h5py/1760/735926690

Apparently h5py tries to build numpy with the oldest version possible to guarantee some functionality. The problem is that old numpy versions rely on this x.locale.h file that was not standard and got removed in recent C standard library versions. “Recent versions of numpy are aware of this fact and handle it fine.”

I still havent figured out how to solve it yet on my limited time, but Im working on it. There is also a workaround mentioned there to tell numpy not to look for it by some define constant, but apparently it could have side some side effects.

I’ll report any new findings.
Best regards.
Eduardo

I still wasn’t able to try it, but wonder why you had problems on JP 4.3, because I remember installing h5py without any hassle on JP 4.3. Can you point me to that discussion?

Thank you,
Best regards,
Eduardo

I didn’t have problem before with JP 4.3 either, at least for when I did in in 2019. I have moved on to 4.4, also didn’t have problem when i did installation a few months ago. I just had to try 4.3 now for something, and this problem occurred.
At first, I installed latest numpy 1.19, and I saw the message complaining about numpy version 1.12. So I uninstalled numpy then reinstall with 1.12. But I just couldn’t
.
I read your post here, so I tried a fresh image to install numpy 1.12 from fresh. But still couldn’t install that version. Then I went ahead with 1.13.3, and it could install. But same old failed error for h5py

It’s not so relevant. But I read this post, and someone suggested an older version install https://stackoverflow.com/questions/37323963/h5py-install-error-failed-with-exit-status-2

So I traced back to the date of this post Official TensorFlow for Jetson Nano! it’s actually right after the release of 2.9.0 version according to the h5py pip release date. So I think whatever buid for 4.3 here is meant for version 2.9.0. Tried it, and no more error.

Hi, thanks a lot for the description.
I’m now (too) also having issues pip installing h5py on JP4.3 (when I never had any issues before, just as you), but can pip install h5py==2.10.0 without any problems. It’s finally starting to look like a solution/workaround.

I will try the same approach on JP 4.4.1 after this.

1 Like

Ok, just tried it on JP 4.4.1 and version of 2.10.0 was successfully installed via pip.
Back on track, thank you.
Best regards.
Eduardo