Difference between revisions of "Install Turtlebot3 Hood Waffle Foxy alsora ros2-tensorflow 20210615"
(→Object Detection Task) |
(→Clue from Running Under Docker) |
||
Line 308: | Line 308: | ||
$ bash ros2-tensorflow/docker/run.sh | $ bash ros2-tensorflow/docker/run.sh | ||
− | + | ||
root@hood:~# ros2 run tf_detection_py server | root@hood:~# ros2 run tf_detection_py server | ||
2021-08-21 19:12:31.941588: 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: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:31.941588: 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: /root/tf_ws/install/tf_interfaces/lib:/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 |
Revision as of 11:16, 29 August 2021
Contents
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
- ROS 2 Tensorflow
- move Install TensorFlow on Ubuntu Linux Hint
- moveTutorial - How to Install TensorFlow 2.0 on Ubuntu 20.04 Medium
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
- ROS 2 Tensorflow See Requirements section
- ROS Perception Vision Msgs
- ROS GPG Key Expiration Incident Carefully read Tiryoh's comment carefully from Kat Scott's posting.
- Cannot Install Any More Foxy or Ubuntu Packages My ticket
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
- This resulted in errors. I found the resolution here:
- Can't resolve package dependencies when building ros for Ubuntu 16.04
$ 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]
Tracking Down the ssd_mobilenet Model - an Addendum
ssd_mobilenet_v1_coco_2017_11_17
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???
Usage Clues
$ sudo bash run.sh Sourcing ROS2 packages... root@hood:~# source tf_ws/install/local_setup.sh root@hood:~# ros2 run tf_detection_py server 2021-08-21 19:12:31.941588: 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: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:31.941645: 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 ssd_mobilenet_v1_coco_2017_11_17 100.0%Succesfully downloaded ssd_mobilenet_v1_coco_2017_11_17 76534733 bytes. Trying to extract archive /usr/local/lib/python3.8/dist-packages/tensorflow/models/research/object_detection/ssd_mobilenet_v1_coco_2017_11_17.tar.gz 2021-08-21 19:12:47.081207: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:47.081271: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303) 2021-08-21 19:12:47.081327: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (hood): /proc/driver/nvidia/version does not exist 2021-08-21 19:12:47.081894: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-08-21 19:12:47.125438: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2) [INFO] [1629573171.671236404] [detection_server]: Load model completed! [INFO] [1629573174.817241482] [detection_server]: Warmup completed! Ready to receive real images!
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.
- Turtlebot3 Waffle NUC Alsora Foxy Tensorflow Install 20210708 Notes and Logs
- Turtlebot3 Waffle NUC Alsora Build Foxy Tensorflow WS 20210810 Notes and Logs
- Turtlebot3 Waffle NUC Alsora Build Foxy Tensorflow WS Again 21200812 Notes and Logs
- Turtlebot3 Waffle NUC Vanilla Tensorflow Install and Test 20210730 Notes and Logs
- Turtlebot3 Waffle NUC ROS Key and vision-msgs Install 20210811 Notes and Logs
Depreciated
Object Detection Task
Terminal 1
This was run under Docker. I noted that the ssd_mobilenet_v1_coco_2017_11_17 downloaded
$ source tf_ws/install/local_setup.sh
root@hood:~# ros2 run tf_detection_py server 2021-08-21 19:12:31.941588: 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: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:31.941645: 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 ssd_mobilenet_v1_coco_2017_11_17 100.0%Succesfully downloaded ssd_mobilenet_v1_coco_2017_11_17 76534733 bytes. Trying to extract archive /usr/local/lib/python3.8/dist-packages/tensorflow/models/research/object_detection/ssd_mobilenet_v1_coco_2017_11_17.tar.gz 2021-08-21 19:12:47.081207: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:47.081271: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303) 2021-08-21 19:12:47.081327: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (hood): /proc/driver/nvidia/version does not exist 2021-08-21 19:12:47.081894: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-08-21 19:12:47.125438: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2) [INFO] [1629573171.671236404] [detection_server]: Load model completed! [INFO] [1629573174.817241482] [detection_server]: Warmup completed! Ready to receive real images!
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.
Note: Both cannot load libcudart.so library. My NUC does not have a NVIDIA card so the library is not installed.
Clue from Running Under Docker
TERMINAL 1
First start up Docker. Notice that ssd_mobilenet_v1_coco_2017_11_17 gets loaded which it doesn't when we are not in that virtual environment.
$ bash ros2-tensorflow/docker/run.sh root@hood:~# ros2 run tf_detection_py server 2021-08-21 19:12:31.941588: 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: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:31.941645: 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 ssd_mobilenet_v1_coco_2017_11_17 100.0%Succesfully downloaded ssd_mobilenet_v1_coco_2017_11_17 76534733 bytes. Trying to extract archive /usr/local/lib/python3.8/dist-packages/tensorflow/models/research/object_detection/ssd_mobilenet_v1_coco_2017_11_17.tar.gz 2021-08-21 19:12:47.081207: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /root/tf_ws/install/tf_interfaces/lib:/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-21 19:12:47.081271: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303) 2021-08-21 19:12:47.081327: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (hood): /proc/driver/nvidia/version does not exist 2021-08-21 19:12:47.081894: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-08-21 19:12:47.125438: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2) [INFO] [1629573171.671236404] [detection_server]: Load model completed! [INFO] [1629573174.817241482] [detection_server]: Warmup completed! Ready to receive real images!