Skip to content

Commit

Permalink
Merge branch 'master' into add_pythoncheck
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada authored Sep 24, 2021
2 parents 127e607 + 16b59f6 commit 65e7e86
Show file tree
Hide file tree
Showing 44 changed files with 1,967 additions and 67 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/python2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# generated by `./generate_action_config.py noetic`
# jsk_travis
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
name: check_python2

container: ubuntu:20.04

steps:
- name: Chcekout
uses: actions/checkout@v2
- name: Check Python2
run: |
apt update -q && apt install -y -q python2
python2 -m compileall .
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ env:
- ROSDEP_ADDITIONAL_OPTIONS='-n -r -v --ignore-src' # run rosdep without -q
matrix:
- CHECK_PYTHON3_COMPILE=true
- CHECK_PYTHON2_COMPILE=true
- ROS_DISTRO=melodic DOCKER_IMAGE_JENKINS="ros-ubuntu:18.04-base" BEFORE_SCRIPT="sudo pip uninstall -y fcn chainer chainercv decorator cupy-cuda91; sudo ln -sf /bin/echo /usr/local/bin/pip; sudo ln -sf /bin/echo /usr/local/bin/pip2" TEST_PKGS="jsk_recognition_msgs" # check https://github.com/jsk-ros-pkg/jsk_recognition/pull/2533
- ROS_DISTRO=indigo
- ROS_DISTRO=indigo CATKIN_TOOLS_CONFIG_OPTIONS="--install" TEST_PKGS='jsk_recognition_msgs' # to skip test
Expand All @@ -52,6 +53,7 @@ before_script:
- if [[ "$ROS_DISTRO" == "melodic" && "$DOCKER_IMAGE_JENKINS" == "" ]]; then export export DOCKER_IMAGE_JENKINS='ros-ubuntu:18.04-pcl'; fi
- if [[ "$ROS_DISTRO" == "noetic" && "$DOCKER_IMAGE_JENKINS" == "" ]]; then export export DOCKER_IMAGE_JENKINS='ros-ubuntu:20.04-pcl'; fi
script:
- if [ "${CHECK_PYTHON2_COMPILE}" == "true" ]; then python2 -m compileall .; exit $?; fi
- if [ "${CHECK_PYTHON3_COMPILE}" == "true" ]; then bash -c "ret=0; trap 'ret=1' ERR; python3 -m compileall .; 2to3 -w -f except -f execfile -f has_key -f import -f raw_input -f zip .; git diff --exit-code . :^.travis > /dev/null; echo Exitting with \$ret; exit \$ret"; exit $?; fi
# use https://github.com/ros-infrastructure/rosdep/pull/694 to respect version_lt for python pip, some package requries python3
- export BEFORE_SCRIPT="sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 cupy-cuda91; $BEFORE_SCRIPT"
Expand Down
8 changes: 4 additions & 4 deletions doc/imagesift/nodes/imagesift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ Extract sift features from input image.
Subscribing Topic
-----------------

- ``image`` (``sensor_msgs/Image``)
- ``/image`` (``sensor_msgs/Image``)

Input image. This triggers output ``Feature0D``.

- ``camera_info`` (``sensor_msgs/CameraInfo``)
- ``/camera_info`` (``sensor_msgs/CameraInfo``)

Input camera_info.


Publishing Topic
----------------

- ``Feature0D`` (``posedetection_msgs/Feature0D``)
- ``/Feature0D`` (``posedetection_msgs/Feature0D``)

This appears with input ``image``.

- ``ImageFeature0D`` (``posedetection_msgs/ImageFeature0D``)
- ``/ImageFeature0D`` (``posedetection_msgs/ImageFeature0D``)

This appears with both inputs ``image`` and ``camera_info``.

Expand Down
176 changes: 146 additions & 30 deletions doc/install_chainer_gpu.rst
Original file line number Diff line number Diff line change
@@ -1,86 +1,195 @@
Install Chainer with GPU Support
================================
Install Chainer/PyTorch with GPU Support
========================================

This documentation describes how to install Chainer with GPU suppport.
This documentation describes how to install Chainer/PyTorch with GPU suppport.


Requirements
------------

- Nvidia GPU (ex. K80, TitanX, GTX 1080Ti).
- Ubuntu (ex. 14.04, 16.04).
- Ubuntu (ex. 14.04, 16.04, 18.04).

You can check whether your PC has a GPU by ``lspci | grep -i nvidia``.

Version Compatibilities for 18.04
---------------------------------

(Recommended) Use CUDA 9.1 from Official ubuntu repository (https://packages.ubuntu.com/bionic/nvidia-cuda-dev)

- Chainer

- chainer == 6.7.0 (last version supoprting python2. See https://github.com/chainer/chainer/releases/tag/v6.7.0)
- cupy-cuda91 == 6.7.0 (chainer v6.7.0 requires cupy/cudnn for hardware acceleration support https://docs.chainer.org/en/v6.7.0/install.html)

- PyTorch

- pytorch == 1.1.0 (Latest pytorch version supporting CUDA 9.1 https://download.pytorch.org/whl/cu90/torch_stable.html)
- CUDA >= 9.0 (Minimum required version for PyTorch 1.1.0 https://pytorch.org/get-started/previous-versions/#v110)

(Experimental) Use CUDA 10.2 from Nvidia Developer's site (https://developer.nvidia.com/cuda-10.2-download-archive)

- Chainer

- chainer == 6.7.0 (last version supoprting python2. See https://github.com/chainer/chainer/releases/tag/v6.7.0)
- cupy >=6.7.0,<7.0.0 (chainer v6.7.0 requires cupy/cudnn for hardware acceleration support https://docs.chainer.org/en/v6.7.0/install.html)
- cuDNN < 8 (cupy 6.7.0 requires cuDNN v5000= and <=v7999)
- CUDA 10.2 (cuDNN v7.6.5 requires CUDA 10.2 https://developer.nvidia.com/rdp/cudnn-archive)

- PyTorch

- pytorch >= 1.4.0
- CUDA >= 9.2 (Minimum required version for PyTorch https://pytorch.org/get-started/previous-versions/#v140)
- Driver Version >= 396.26 (From CUDA Toolkit and Corresponding Driver Versions in https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html)

Install CUDA
------------

- Download deb file from https://developer.nvidia.com/cuda-downloads?target_os=Linux::
- Ubuntu 14.04 : Download deb file from https://developer.nvidia.com/cuda-downloads?target_os=Linux::

```bash
# If you'd like to use CUDA8.0 on Ubuntu 14.04.
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb
mv cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
```

- Add below to your `~/.bashrc`::

```bash
# setup cuda & cudnn
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib:/usr/lib:$LIBRARY_PATH
export CPATH=/usr/include:$CPATH
export CFLAGS=-I/usr/include
export LDFLAGS="-L/usr/local/lib -L/usr/lib"
if [ -e /usr/local/cuda ]; then
export CUDA_PATH=/usr/local/cuda
export PATH=$CUDA_PATH/bin:$PATH
export CPATH=$CUDA_PATH/include:$CPATH
export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$CUDA_PATH/lib:$LD_LIBRARY_PATH
export CFLAGS=-I$CUDA_PATH/include
export LDFLAGS="-L$CUDA_PATH/lib64 -L$CUDA_PATH/lib"
fi
```


- Ubuntu 16.04 : Download deb file from https://developer.nvidia.com/cuda-downloads?target_os=Linux::

```bash
# If you'd like to use CUDA9.2 on Ubuntu 16.04.
# Choose the green buttons on the web page like x86_64 -> Ubuntu -> version -> deb (network).
# Excute 1-3 and then, change step 4 as follows:
sudo apt install cuda-9-2
```

- Ubuntu 18.04 : You can use CUDA 9.1 by deafult

```bash
sudo apt install nvidia-cuda-toolkit
sudo apt install nvidia-cuda-dev
- (Experimental) Ubuntu 18.04 : CUDA 10.2 is the latest version which supports `jsk_perception`. Download deb file from https://developer.nvidia.com/cuda-downloads?target_os=Linux::
```bash
# If you'd like to use CUDA10.2 on Ubuntu 18.04.
# goto https://developer.nvidia.com/cuda-10.2-download-archive
# Choose the green buttons on the web page like x86_64 -> Ubuntu -> version -> deb (network).
# Excute all steps, but change the last step as follows:
sudo apt install cuda-10-2
```

- If you install CUDA from nvidia, Make sure to uninstall CUDA tools from packages.ubuntu.com

```bash
sudo apt remove nvidia-cuda-toolkit
sudo apt remove nvidia-cuda-dev
```

- Also set environment variables to ~/.bashrc

```bash
# set PATH for cuda 10.0 installation
if [ -d "/usr/local/cuda-10.2/bin/" ]; then
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CFLAGS=-I/usr/local/cuda-10.2/include
fi
```

- After rebooting, you can see the memory usage of your GPU by ``nvidia-smi``

Install CUDNN
-------------

- If you install `pip install cupy-cuda91`, you do not need to install CUDNN manually. (c.f. https://github.com/jsk-ros-pkg/jsk_visualization/issues/809). Thus, default 18.04 user can use CUDA 9.1 and `cupy-cuda91==6.7.0` for `chainer==6.7.0` and you can SKIP this section.

Installing CUDNN manually only requires for experimental user who install CUDA 10.2 manually.

- You need to login at https://developer.nvidia.com/cudnn
- Go to cuDNN Download and choose version
- Download deb files of cuDNN Runtime Library and cuDNN Developer Library

::

```bash
# If you'd like to install cuDNN for CUDA9.2 on Ubuntu 16.04
# Download cuDNN v7.3.1 Runtime Library for Ubuntu16.04 (Deb)
sudo dpkg -i libcudnn7_7.3.1.20-1+cuda9.2_amd64.deb
# Download cuDNN v7.3.1 Developer Library for Ubuntu16.04 (Deb)
sudo dpkg -i libcudnn7-dev_7.3.1.20-1+cuda9.2_amd64.deb
# Download cuDNN v7.6.5 Developer Library for Ubuntu18.04 (Deb)
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
```

Install Chainer
---------------

::

pip install chainer

```bash
sudo pip install chainer==6.7.0
```

Install Cupy
------------

- Add below to your `~/.bashrc`::
- (Default) Chainer 6.7.0 requires CuPy 6.7.0 and if you have CUDA 9.1, you can use CuPy pre-compiled binary package.


- Pre-compiled Install Cupy for CUDA 9.1 ::

```bash
sudo pip install cupy-cuda91==6.7.0
```

- (Experimental) If you have newer CUDA version. You need to install CuPy with source distribution. This requires CUDNN before you run `pip install cupy` .

- Source Install Cupy for CUDA 10.2 ::

```bash
sudo pip install -vvv cupy --no-cache-dir
```

# setup cuda & cudnn
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib:/usr/lib:$LIBRARY_PATH
export CPATH=/usr/include:$CPATH
export CFLAGS=-I/usr/include
export LDFLAGS="-L/usr/local/lib -L/usr/lib"
if [ -e /usr/local/cuda ]; then
export CUDA_PATH=/usr/local/cuda
export PATH=$CUDA_PATH/bin:$PATH
export CPATH=$CUDA_PATH/include:$CPATH
export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$CUDA_PATH/lib:$LD_LIBRARY_PATH
export CFLAGS=-I$CUDA_PATH/include
export LDFLAGS="-L$CUDA_PATH/lib64 -L$CUDA_PATH/lib"
fi

- Install Cupy::
Install PyTorch
---------------

- 18.04 provides CUDA 9.1 by defualt. To install PyTorch compatible with this version, download following wheel from https://download.pytorch.org/whl/cu90/torch_stable.html, and install manually.

```bash
sudo pip install torch-1.1.0-cp27-cp27mu-linux_x86_64.whl
sudo pip install torchvision-0.3.0-cp27-cp27mu-manylinux1_x86_64.whl
```

sudo bash
pip install -vvv cupy --no-cache-dir
- (Experimental) If you manually install CUDA 10.2 manually, you can use latest PyTorch.

```bash
sudo pip install torch==1.4.0
```

Try Samples
- See https://github.com/jsk-ros-pkg/jsk_recognition/pull/2601#issuecomment-876948260 for more info.

Try Chainer Samples
-----------

You can try to run samples to check if the installation succeeded::
Expand All @@ -89,6 +198,13 @@ You can try to run samples to check if the installation succeeded::
roslaunch jsk_perception sample_people_pose_estimation_2d.launch GPU:=0
roslaunch jsk_perception sample_regional_feature_based_object_recognition.launch GPU:=0

Try PyTorch Samples
-----------

You can try to run samples to check if the installation succeeded::

roslaunch jsk_perception sample_hand_pose_estimation_2d.launch gpu:=0

Trouble Shooting
----------------

Expand Down
83 changes: 83 additions & 0 deletions doc/jsk_perception/nodes/aws_auto_checkin_app.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
aws_auto_cehckin_app.py
=========================

What is this?
-------------

.. image:: https://d1.awsstatic.com/Solutions/Solutions%20Category%20Template%20Draft/Solution%20Architecture%20Diagrams/auto-check-in-app-architecture.8baa84b79c2294d035c7b9cee323d7c9ba53a43a.png

Face recognition using Amazon Rekognition, see
https://aws.amazon.com/solutions/implementations/auto-check-in-app/
for more info.

Subscribing Topic
-----------------


* ``~image`` (``sensor_msgs/Image``)

Raw image.

* ``~face_roi`` (``opencv_apps/FaceArrayStamped``)

Rectangles on the face of input image. Use ROI value.
```
msg.faces[].face.x : X coordinates of the center of the face image in the ~image input
msg.faces[].face.y : Y coordinates of the center of the face image in the ~image input
msg.faces[].face.width : Width of the face image
msg.faces[].face.height : Height of the face iamge
```

Publishing Topic
----------------

* ``~face_name`` (``opencv_apps/FaceArrayStamped``)

Publish recognized face name as well as face image. The face.{x,y,width,height} corresponds to input `face_roi`, that means x, y is the center of face rectangle.

Parameters
----------

* ``~use_window`` (Bool, default: ``False``)

Show input image on the window, if it is true.

* ``~env_path`` (String, default: ``env.json``)

Json file for environment variables to run aws auto-checkin app. You
can find how to generate this file on
https://aws.amazon.com/jp/builders-flash/202004/auto-checkin-app/.
In addition to that, you need to add "UserName" and "UserPassword"
```
{
"Region": "%%REGION%%",
"ApiEndpoint" : "%%REST_API_ID%%.execute-api.%%REGION%%.amazonaws.com/prod/rekognize_face",
"CognitoUserPoolId": "%%COGNITO_USER_POOL_ID%%",
"CognitoUserPoolClientId": "%%COGNITO_USER_POOL_CLIENT_ID%%",
"FaceAreaThreshold": 1e4,
"FaceMarginRatio": 0.2,
"FaceSimilarityThreshold": 90,
"CroppedImageWidth": 540,
"CroppedImageHeight": 540,
"NameTtlSec": 10,
"UseDeepLeaningForDetector": true,
"UserName": "%%YOUR_USER_NAME%%",
"UserPassword": "%%YOUR_PASSWORD%%"
}
```

Sample
------

.. code-block:: bash
roslaunch jsk_perception sample_aws_auto_checkin_app.launch use_window:=true
For JSK user, Download `env.json` file from
[Gdrive](https://drive.google.com/file/d/1WUrRxPtT0ZuRx-IqjGwDBqeR5vZVTkB1/view?usp=sharing)
and put this under `/tmp` directory to run sample code.

To add new people to face database, add face image file to [Amazon
S3](https://console.aws.amazon.com/s3),
`auto-check-in-gapp-register...` buckets
Loading

0 comments on commit 65e7e86

Please sign in to comment.