Closed2

Installation issues with TensorFlow for the Jetson Nano on virtualenv(virtualenvwrapper)

nb.onb.o

Create virtualenv.

$ mkvirtualenv --python=python3 tensorflow
created virtual environment CPython3.6.9.final.0-64 in 508ms
  creator CPython3Posix(dest=/home/jetson/.virtualenvs/tensorflow, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/jetson/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==59.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
virtualenvwrapper.user_scripts creating /home/jetson/.virtualenvs/tensorflow/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/jetson/.virtualenvs/tensorflow/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/jetson/.virtualenvs/tensorflow/bin/preactivate
virtualenvwrapper.user_scripts creating /home/jetson/.virtualenvs/tensorflow/bin/postactivate
virtualenvwrapper.user_scripts creating /home/jetson/.virtualenvs/tensorflow/bin/get_env_details

Install system packages required by TensorFlow:

$ sudo apt-get update
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran

Install and upgrade pip3.

$ pip3 install testresources setuptools==49.6.0

Install the Python package dependencies.

$ pip3 install --no-deps numpy==1.19.4 future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 protobuf pybind11 cython pkgconfig

Install h5py and error occures.

$ env H5PY_SETUP_REQUIRES=0 pip3 install h5py==3.1.0
Collecting h5py==3.1.0
  Downloading h5py-3.1.0.tar.gz (371 kB)
     |████████████████████████████████| 371 kB 2.2 MB/s            
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cached-property in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from h5py==3.1.0) (1.5.2)
Requirement already satisfied: numpy>=1.12 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from h5py==3.1.0) (1.19.4)
Building wheels for collected packages: h5py
  Building wheel for h5py (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/jetson/.virtualenvs/tensorflow/bin/python /home/jetson/.virtualenvs/tensorflow/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpa1xbvrse
       cwd: /tmp/pip-install-fgo_9358/h5py_c471778c88d44733a4d6d0024ae2bad7
  Complete output (105 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.6
  creating build/lib.linux-aarch64-3.6/h5py
  copying h5py/ipy_completer.py -> build/lib.linux-aarch64-3.6/h5py
  copying h5py/__init__.py -> build/lib.linux-aarch64-3.6/h5py
  copying h5py/h5py_warnings.py -> build/lib.linux-aarch64-3.6/h5py
  copying h5py/version.py -> build/lib.linux-aarch64-3.6/h5py
  creating build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/group.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/attrs.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/selections.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/selections2.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/base.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/files.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/compat.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/__init__.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/dataset.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/filters.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/datatype.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/vds.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  copying h5py/_hl/dims.py -> build/lib.linux-aarch64-3.6/h5py/_hl
  creating build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5p.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5d_direct_chunk.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_filters.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_attrs.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dtype.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_completions.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_objects.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/conftest.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_attrs_data.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dataset_swmr.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5t.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/common.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dims_dimensionproxy.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_file.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_file2.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_errors.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_big_endian_file.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_base.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5pl.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_file_image.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_slicing.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dataset_getitem.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dataset.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/__init__.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_h5f.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_group.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_selections.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_attribute_create.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_datatype.py -> build/lib.linux-aarch64-3.6/h5py/tests
  copying h5py/tests/test_dimension_scales.py -> build/lib.linux-aarch64-3.6/h5py/tests
  creating build/lib.linux-aarch64-3.6/h5py/tests/data_files
  copying h5py/tests/data_files/__init__.py -> build/lib.linux-aarch64-3.6/h5py/tests/data_files
  creating build/lib.linux-aarch64-3.6/h5py/tests/test_vds
  copying h5py/tests/test_vds/test_highlevel_vds.py -> build/lib.linux-aarch64-3.6/h5py/tests/test_vds
  copying h5py/tests/test_vds/test_lowlevel_vds.py -> build/lib.linux-aarch64-3.6/h5py/tests/test_vds
  copying h5py/tests/test_vds/__init__.py -> build/lib.linux-aarch64-3.6/h5py/tests/test_vds
  copying h5py/tests/test_vds/test_virtual_source.py -> build/lib.linux-aarch64-3.6/h5py/tests/test_vds
  copying h5py/tests/data_files/vlen_string_dset_utc.h5 -> build/lib.linux-aarch64-3.6/h5py/tests/data_files
  copying h5py/tests/data_files/vlen_string_dset.h5 -> build/lib.linux-aarch64-3.6/h5py/tests/data_files
  copying h5py/tests/data_files/vlen_string_s390x.h5 -> build/lib.linux-aarch64-3.6/h5py/tests/data_files
  running build_ext
  Traceback (most recent call last):
    File "/home/jetson/.virtualenvs/tensorflow/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/home/jetson/.virtualenvs/tensorflow/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/jetson/.virtualenvs/tensorflow/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 262, in build_wheel
      metadata_directory)
    File "/tmp/pip-build-env-jaz4yv95/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 231, in build_wheel
      wheel_directory, config_settings)
    File "/tmp/pip-build-env-jaz4yv95/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-jaz4yv95/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 183, in <module>
      cmdclass = CMDCLASS,
    File "/tmp/pip-build-env-jaz4yv95/overlay/lib/python3.6/site-packages/setuptools/__init__.py", line 153, 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 "/tmp/pip-build-env-jaz4yv95/overlay/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    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 "/usr/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    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-fgo_9358/h5py_c471778c88d44733a4d6d0024ae2bad7/setup_build.py", line 121, in run
      from Cython import __version__ as cython_version
  ModuleNotFoundError: No module named 'Cython'
  ----------------------------------------
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects
nb.onb.o

Solution

Create a symbolic link for xlocale.h

$ sudo ln -s /usr/include/locale.h /usr/include/xlocale.

install h5py remove H5PY_SETUP_REQUIRES

$ pip3 install h5py==3.1.0
Collecting h5py==3.1.0
  Using cached h5py-3.1.0.tar.gz (371 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.12 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from h5py==3.1.0) (1.19.4)
Collecting cached-property
  Downloading cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Building wheels for collected packages: h5py
  Building wheel for h5py (pyproject.toml) ... done
  Created wheel for h5py: filename=h5py-3.1.0-cp36-cp36m-linux_aarch64.whl size=4428704 sha256=f14ce388201ab2295769bf43021f26dc294cb14573a37857abdfaa712a4af9f0
  Stored in directory: /home/jetson/.cache/pip/wheels/7a/a9/52/00330d144164b95ed1c699f64f6e8576850b29ef1aa2b85be5
Successfully built h5py
Installing collected packages: cached-property, h5py
Successfully installed cached-property-1.5.2 h5py-3.1.0

Finaly, install tensorflow

$ pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v46 tensorflow
Looking in indexes: https://pypi.org/simple, https://developer.download.nvidia.com/compute/redist/jp/v46
Collecting tensorflow
  Downloading https://developer.download.nvidia.com/compute/redist/jp/v46/tensorflow/tensorflow-2.6.2%2Bnv21.12-cp36-cp36m-linux_aarch64.whl (317.1 MB)
     |████████████████████████████████| 317.1 MB 2.7 kB/s             
Collecting tensorboard<2.7,>=2.6.0
  Downloading tensorboard-2.6.0-py3-none-any.whl (5.6 MB)
     |████████████████████████████████| 5.6 MB 3.0 MB/s            
Requirement already satisfied: protobuf>=3.9.2 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (3.19.4)
Collecting flatbuffers~=1.12.0
  Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB)
Collecting astunparse~=1.6.3
  Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting six~=1.15.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting clang~=5.0
  Downloading clang-5.0.tar.gz (30 kB)
  Preparing metadata (setup.py) ... done
Collecting termcolor~=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: keras-preprocessing~=1.1.2 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (1.1.2)
Collecting typing-extensions~=3.7.4
  Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Requirement already satisfied: wheel~=0.35 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (0.37.1)
Collecting wrapt~=1.12.1
  Downloading wrapt-1.12.1.tar.gz (27 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: gast==0.4.0 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (0.4.0)
Collecting google-pasta~=0.2
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 1.5 MB/s            
Collecting grpcio<2.0,>=1.37.0
  Downloading grpcio-1.44.0-cp36-cp36m-manylinux_2_17_aarch64.whl (54.3 MB)
     |████████████████████████████████| 54.3 MB 13 kB/s             
Collecting tensorflow-estimator<2.7,>=2.6.0
  Downloading tensorflow_estimator-2.6.0-py2.py3-none-any.whl (462 kB)
     |████████████████████████████████| 462 kB 3.4 MB/s            
Collecting absl-py==0.12.0
  Downloading absl_py-0.12.0-py3-none-any.whl (129 kB)
     |████████████████████████████████| 129 kB 2.5 MB/s            
Collecting keras<2.7,>=2.6.0
  Downloading keras-2.6.0-py2.py3-none-any.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 2.9 MB/s            
Requirement already satisfied: numpy~=1.19.2 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (1.19.4)
Requirement already satisfied: h5py~=3.1.0 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorflow) (3.1.0)
Collecting opt-einsum~=3.3.0
  Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)
     |████████████████████████████████| 65 kB 682 kB/s            
Requirement already satisfied: cached-property in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from h5py~=3.1.0->tensorflow) (1.5.2)
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.35.0-py2.py3-none-any.whl (152 kB)
     |████████████████████████████████| 152 kB 3.1 MB/s            
Collecting tensorboard-data-server<0.7.0,>=0.6.0
  Downloading tensorboard_data_server-0.6.1-py3-none-any.whl (2.4 kB)
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-2.0.3-py3-none-any.whl (289 kB)
     |████████████████████████████████| 289 kB 3.7 MB/s            
Collecting requests<3,>=2.21.0
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 1.1 MB/s             
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.8.1-py3-none-any.whl (781 kB)
     |████████████████████████████████| 781 kB 4.4 MB/s            
Collecting markdown>=2.6.8
  Downloading Markdown-3.3.6-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 2.5 MB/s            
Requirement already satisfied: setuptools>=41.0.0 in ./.virtualenvs/tensorflow/lib/python3.6/site-packages (from tensorboard<2.7,>=2.6.0->tensorflow) (49.6.0)
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.6-py2.py3-none-any.whl (18 kB)
Collecting rsa<5,>=3.1.4
  Downloading rsa-4.8-py3-none-any.whl (39 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.2.4-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 1.4 MB/s            
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
Collecting importlib-metadata>=4.4
  Downloading importlib_metadata-4.8.3-py3-none-any.whl (17 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
     |████████████████████████████████| 149 kB 656 kB/s            
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 973 kB/s            
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 33 kB/s             
Collecting dataclasses
  Downloading dataclasses-0.8-py3-none-any.whl (19 kB)
Collecting zipp>=0.5
  Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 588 kB/s            
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.2.0-py3-none-any.whl (151 kB)
     |████████████████████████████████| 151 kB 741 kB/s            
Building wheels for collected packages: clang, termcolor, wrapt
  Building wheel for clang (setup.py) ... done
  Created wheel for clang: filename=clang-5.0-py3-none-any.whl size=30703 sha256=3bda91c4ae507a17de70b00385351757f75b21a49c296650b846fe8620acf0d3
  Stored in directory: /home/jetson/.cache/pip/wheels/22/4c/94/0583f60c9c5b6024ed64f290cb2d43b06bb4f75577dc3c93a7
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=665ef18cf19964e1bef17fff21843f2ca048c13eb70de2bae90267c4045d2781
  Stored in directory: /home/jetson/.cache/pip/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdc
  Building wheel for wrapt (setup.py) ... done
  Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_aarch64.whl size=67105 sha256=9344a86eb092a48b246d08c1abcd27a08bdf52134cd18c538f555ddd839d91f7
  Stored in directory: /home/jetson/.cache/pip/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
Successfully built clang termcolor wrapt
Installing collected packages: urllib3, pyasn1, idna, charset-normalizer, certifi, zipp, typing-extensions, six, rsa, requests, pyasn1-modules, oauthlib, cachetools, requests-oauthlib, importlib-metadata, google-auth, dataclasses, werkzeug, tensorboard-plugin-wit, tensorboard-data-server, markdown, grpcio, google-auth-oauthlib, absl-py, wrapt, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras, google-pasta, flatbuffers, clang, astunparse, tensorflow
Successfully installed absl-py-0.12.0 astunparse-1.6.3 cachetools-4.2.4 certifi-2021.10.8 charset-normalizer-2.0.12 clang-5.0 dataclasses-0.8 flatbuffers-1.12 google-auth-1.35.0 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.44.0 idna-3.3 importlib-metadata-4.8.3 keras-2.6.0 markdown-3.3.6 oauthlib-3.2.0 opt-einsum-3.3.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.27.1 requests-oauthlib-1.3.1 rsa-4.8 six-1.15.0 tensorboard-2.6.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.6.2+nv21.12 tensorflow-estimator-2.6.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.26.8 werkzeug-2.0.3 wrapt-1.12.1 zipp-3.6.0

Check installation.

$ python -c "import tensorflow; print(tensorflow.__version__)"
2.6.2
このスクラップは2022/02/20にクローズされました