TensorFlow and ROS Kinetic with Python 3.5 Natively

Setup

Native setup, no venv
1. Create working directory
$ mkdir ~/py3_tf_ros && cd ~/py3_tf_ros

  1. Install Python 3.5
    $ sudo apt-get install python3-dev python3-yaml python3-setuptools

  2. Install rospkg for Python 3

$ git clone git://github.com/ros/rospkg.git
$ cd roskpkg && sudo python3 setup.py install
  1. Install catkin_pkg for Python 3
$ git clone git://github.com/ros-infrastructure/catkin_pkg.git
$ cd catkin_pkg && sudo python3 setup.py install && cd ..
  1. Install catkin for Python 3
$ git clone git://github.com/ros/catkin.git
$ cd catkin && sudo python3 setup.py install && cd ..
  1. Install OpenCV for Python 3
    pip3 install opencv-python

  2. Download desired TensorFlow version

  3. Setup Nvidia Drivers, CUDA and CUDNN according to the TensorFlow version.

  4. Install downloaded TensforFlow package
    pip3 install --user --upgrade tensorflow-package.whl

  5. Check that symbolic link /usr/local/cuda corresponds to the CUDA version required by TensorFlow. (if there are several CUDA versions installed in the system).

  6. Test TensorFlow
    python -c "import tensorflow as tf; print(tf.__version__)"
    This should display the version 1.XX.YY you selected.

  7. It is possible to import ros and import tensorflow.

  8. If cv2 package is also required:

sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')

import cv2

sys.path.append(`/opt/ros/kinetic/lib/python2.7/dist-packages`)

import ros