Adding tensorflow to Orbitty + Nvidia Jetson TX2 container

I’m trying to add python 3.6, pip3 and tensorflow 1.13.1 to an Orbitty + Nvidia Jetson TX2 container.

Instructions: https://devtalk.nvidia.com/default/topic/1038957/jetson-tx2/tensorflow-for-jetson-tx2-/

pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42  tensorflow-gpu==1.13.1+nv19.5 --user

Unfortunately, the “resin/orbitty-tx2-debian:stretch” base container has python 3.5.3. Perhaps I should switch to the latest balena version. Instead I tried:

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-dev \
    && python3 --version

but that is still Python 3.5.3. How do I get Python 3.6?

I switched to “balenalib/jetson-tx2-debian-python:3.6.8-build” and was able to install tensorflow but I still need to solve this error:

# python3
Python 3.6.8 (default, Jan 12 2019, 04:57:27) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/local/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.local/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/local/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

ah, looks like I need to install CUDA 10:

/usr/local/cuda-9.0/doc/man/man7/libcublas.so.7
/usr/local/cuda-9.0/doc/man/man7/libcublas.7
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas.so.9.0.252
/usr/local/cuda-9.0/targets/aarch64-linux/lib/stubs/libcublas.so
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas_device.a
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas.so
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas_static.a

Hey Jason,

Great to see you’re making progress. Let us know if you still need any help!

I am going through the same process (although with version 1.11.0) and seem to experience a memory error. Did you succeed with version 1.13.1 @jason10?

Sorry, I had to switch to a different hardware platform before fully finishing the project.

This is what I had for my dockerfile.template for the service using tensorflow. I cannot confirm that it worked but maybe it will give you some ideas.

https://github.com/eiodiagnostics/balena-jetson-tx2-experiments

FROM balenalib/jetson-tx2-debian-python:3.6.8-build
LABEL Description=“This image is used create a privileged container for Nvidia Jetson TX2 using BalenaOS”
LABEL Vendor=“EIO Diagnostics”
LABEL Version=“1.0”

SHELL ["/bin/bash", “-cx”]

switch on systemd init system in container – requires “privileged: true” in docker-compose.yml

ENV INITSYSTEM on

retry curl after a delay, follow moved files

ARG CURL_OPTS="–max-time 10 --retry 5 --retry-delay 10 --location"

WORKDIR /usr/src/app
COPY ./install*.bash ./

################################################

START SNIPPET FROM: https://github.com/open-horizon/cogwerx-jetson-tx2/Dockerfile.cudabase

ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra${LD_LIBRARY_PATH:+:{LD_LIBRARY_PATH}}" ENV PATH="/root/.local/bin:/usr/local/cuda/bin{PATH:+:${PATH}}"
RUN source ./installCuda.bash
####################################################################

END SNIPPET FROM: https://github.com/open-horizon/cogwerx-jetson-tx2

####################################################################

###################################################################

Install Python3-dev and Tensorflow

For Nvidia Jetson see

https://devtalk.nvidia.com/default/topic/1038957/jetson-tx2/tensorflow-for-jetson-tx2-/

Python 3.6+JetPack4.2

pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 \

tensorflow-gpu==1.13.1+nv19.5 --user

RUN apt-get update && apt-get install -y --no-install-recommends
python3-dev
libhdf5-serial-dev
hdf5-tools
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*
&& pip3 install numpy --user
&& pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42
tensorflow-gpu==1.13.1+nv19.5 --user

WORKDIR /usr/src/app
COPY runCommand.bash verifyCuda.bash ./
CMD ["/usr/src/app/runCommand.bash"]