Difference between revisions of "Install Turtlebot3 Hood Waffle Foxy alsora ros2-tensorflow 20210615"

From wikidb
Jump to: navigation, search
(Build and install the ros2-tensorflow package)
(Object Detection Task)
Line 198: Line 198:
 
   
 
   
 
   $ ros2 run tf_detection_py server
 
   $ ros2 run tf_detection_py server
         2021-08-13 00:11:25.648086: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/eepp/tf_ws/install/tf_interfaces/lib:/home/eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/install/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:       ...
+
         2021-08-13 00:11:25.648086: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/eepp/tf_ws/install/tf_interfaces/lib:/home/eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/install/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:
 +
        ...
 
         ...
 
         ...
  

Revision as of 11:54, 21 August 2021

Experience

I started here with the Tensorflow requirements for Foxy and got into trouble. So I changed my strategy to a vanilla Tensorflow and other required components install. There may be overlap and the order my need fine tuning

Documentation

Requirements

Required Dependencies

  • Foxy: Installed

Rosdep Dependencies

OpenCV Python

 pip -V
     pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

v 19.3 is minimum.

 $ pip install opencv-python

It was already installed.

Tensorflow

Vision Msgs

ROS Foxy's vision-msgs package is required. However, the ROS key had expired causing some confusion.

References

Install ROS Key

If your ROS key has expired

 $ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

 $ sudo apt update

Insal vission-msgs

$ sudo apt install ros-foxy-vision-msgs

Optional Dependencies

Tensorflow Object Detection Models

I tried going to the following link given by Alsora. The link is broken.

I may have installed the models when I was testing a Udacity Python3 script. See the "Executing Lesson 3 from the Udacity Course" section on page Hood Ubuntu Vanilla Tensorflow Install and Test 20210708

 $ pip install -U tensorflow_datasets

Tensorflow Slim

 $ pip install --upgrade tf_slim

Docker

To use Docker

Hood ROS 2 Foxy Docker 20210814

Build

Create Foxy Tensoryflow work space

 $ git clone https://github.com/alsora/ros2-tensorflow.git $HOME/ros2-tensorflow
       Cloning into '/home/eepp/ros2-tensorflow'...
       ...

 $ mkdir -p $HOME/tf_ws/src

 $ cd $HOME/tf_ws

 $ ln -s $HOME/ros2-tensorflow/ros2-tensorflow src

Install dependencies

 $ rosdep install --from-paths src --ignore-src --rosdistro foxy -y
 $ rosdep install --from-paths src --ignore-src --rosdistro foxy -y -r

Install Object Detection Models

 $ sudo apt-get install -y protobuf-compiler python-lxml python-tk
       ...
       ...

 $ pip install --user Cython contextlib2
       ...
       

The next 3 installs were already satisfied. No additional action.

 $ pip install --user Cython jupyter

 $ pip install --user Cython matplotlib

 $ pip install --user Cython Pillow

The following failed.

 cd usr/local/lib/python3.8/dist-packages/tensorflow/models/research

Corrected

 cd /usr/local/lib/python3.8/dist-packages/tensorflow/models/research

The following failed.

  $ protoc object_detection/protos/*.proto --python_out=.

Corrected

 $ sudo protoc object_detection/protos/*.proto --python_out=.

Missed this the first time I installed

 $ echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/dist-packages/tensorflow/models/research' >> $HOME/.bashrc

 $ tail ~/.bashrc
       export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/dist-packages/tensorflow/models/research

Install tf_slim

tf_slim installed earlier. See Optional Dependencies above.


Build and install the ros2-tensorflow package

Double check the symbolic link

 $ cd

 $ ll tf_ws/src/
       total 8
       drwxrwxr-x 2 eepp eepp 4096 Aug 12 23:43 ./
       drwxrwxr-x 3 eepp eepp 4096 Aug 12 23:43 ../
       lrwxrwxrwx 1 eepp eepp   42 Aug 12 23:43 ros2-tensorflow -> /home/eepp/ros2-tensorflow/ros2-tensorflow/
 $ cd tf_ws

The following fails

 $ colcon build

Corrected by using symlink-install switch

 $ colcon build --symlink-install
       Starting >>> ros2_tf_core
       Starting >>> tf_interfaces
       Finished <<< ros2_tf_core [1.33s]                                             
       Finished <<< tf_interfaces [11.9s]                       
       Starting >>> tf_classification_py
       Starting >>> tf_detection_py                        
       Finished <<< tf_classification_py [1.52s]                           
       Finished <<< tf_detection_py [1.52s]
       Starting >>> ros2_tensorflow
       Finished <<< ros2_tensorflow [1.49s]                   

       Summary: 5 packages finished [15.1s]

Usage

Set up environment by doing this in each terminal.

 $ source tf_ws/install/local_setup.sh

Object Detection Task

Terminal 1

 $ source tf_ws/install/local_setup.sh 

 $ ros2 run tf_detection_py server
       2021-08-13 00:11:25.648086: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/eepp/tf_ws/install/tf_interfaces/lib:/home/eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/install/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:  
       ...
       ...

Need to dig into these errors

Terminal 2

 $ source tf_ws/install/local_setup.sh

 $ ros2 run tf_detection_py client_test
       2021-08-13 00:12:29.450154: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/eepp/tf_ws/install/tf_interfaces/lib:/home /eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/install/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
       2021-08-13 00:12:29.450190: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
       Downloading data from http://farm9.staticflickr.com/8036/7946162344_ee2e1a814e_z.jpg
          8192/Unknown - 0s 0us/step[INFO] [1628827952.451718517] [client_test]: service not available, waiting again...
       [INFO] [1628827953.455543297] [client_test]: service not available, waiting again...
       [INFO] [1628827954.459358797] [client_test]: service not available, waiting again...
       [INFO] [1628827955.463214479] [client_test]: service not available, waiting again...
       [INFO] [1628827956.466590696] [client_test]: service not available, waiting agai

Kind of wanted to start.

TBD: Both cannot load libcudart.so library. I wonder if that is a library I decided I didn't need. NVIDIA library???

Notes and Logs

The install Tensorflow Foxy install went badly. So I went for a simpler vanilla Tensorflow install that did not integrate with ROS2.