Skip to content

Commit

Permalink
Update to 1.0 release
Browse files Browse the repository at this point in the history
- The bindings are now shipped with the SDK. Update import path and documentation for that.
- Optimized test3 app performance by adding queues.
- Adjust ssd-parser app config to work on NX. Added instructions for running this app on Nano.
- Config updates to sync up with the SDK.
  • Loading branch information
nv-zhliu committed Aug 4, 2020
1 parent 2931f6b commit 971626b
Show file tree
Hide file tree
Showing 25 changed files with 188 additions and 121 deletions.
14 changes: 13 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [Error on setting string field](#faq5)
* [Pipeline unable to perform at real time](#faq6)
* [Triton container problems with multi-GPU setup](#faq7)
* [ModuleNotFoundError: No module named 'pyds'] (#faq8)

<a name="faq0"></a>
### Application fails to work with mp4 stream
Expand Down Expand Up @@ -93,10 +94,21 @@ The application appears to be stuck without any playback activity.
a) probe() callbacks are synchronous and thus holds the buffer
(info.get_buffer()) from traversing the pipeline until user return.
b) loops inside probe() callback could be costly in python.


<a name="faq7"></a>
### Triton container problems with multi-GPU setup
The Triton Inference Server plugin currently only supports single-GPU usage.
When running the docker, please specify
`--gpus device=<GPU ID>`
e.g.: `--gpus device=0`
e.g.: `--gpus device=0`


<a name="faq8"></a>
### ModuleNotFoundError: No module named 'pyds'
The pyds extension is installed under /opt/nvidia/deepstream/deepstream/lib
The sample applications all include this path via the is_aarch_64 module.
A setup.py is also provided to install this extension into standard path.
Currently this needs to be run manually:
$ cd /opt/nvidia/deepstream/deepstream/lib
$ python3 setup.py install
32 changes: 11 additions & 21 deletions HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This guide provides resources for DeepStream application development in Python.
## Prerequisites

* Ubuntu 18.04
* [DeepStream SDK 5.0 Developer Preview](https://developer.nvidia.com/deepstream-download) or later
* [DeepStream SDK 5.0](https://developer.nvidia.com/deepstream-download) or later
* Python 3.6
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.14.5

Expand All @@ -38,13 +38,13 @@ If missing, install with the following steps:
<a name="run_samples"></a>
## Running Sample Applications

Download the release package and unpack it under DS 5.0 installation:
```tar xf ds_pybind_v0.9.tbz2 -C <DeepStream 5.0 ROOT>/sources```
Clone the deepstream_python_apps repo under <DeepStream 5.0 ROOT>/sources:
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps

This will create the following directory:
```<DeepStream 5.0 ROOT>/sources/python```
```<DeepStream 5.0 ROOT>/sources/deepstream_python_apps```

The Python apps and bindings are under the "python" directory.
The Python apps are under the "apps" directory.
Go into each app directory and follow instructions in the README.

NOTE: The app configuration files contain relative paths for models.
Expand All @@ -60,23 +60,13 @@ See [sample applications](apps/) main functions for pipeline construction exampl

DeepStream MetaData contains inference results and other information used in analytics. The MetaData is attached to the Gst Buffer received by each pipeline component. The metadata format is described in detail in the [SDK MetaData documentation](https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream_Plugin_Manual%2Fdeepstream_plugin_metadata.03.1.html) and [API Guide](https://docs.nvidia.com/metropolis/deepstream/python-api/index.html).

The SDK MetaData library is developed in C/C++. Python bindings provide access to the MetaData from Python applications. The bindings are provided in a compiled module, available for x86_64 and Jetson platforms. Find them in the release package with the following layout:
```
bindings
|- x86_64
| |- pyds.so
|- jetson
|- pyds.so
```
The SDK MetaData library is developed in C/C++. Python bindings provide access to the MetaData from Python applications. The bindings are provided in a compiled module, available for x86_64 and Jetson platforms. This module, pyds.so, is available as part of the DeepStream SDK installation under <DeepStream Root>/lib directory.

Applications can import the module thus:
```python
import sys
sys.path.append('../') # Add path to the bindings directory
# The common/is_aarch64.py module adds the platform-specific path to pyds module
from common.is_aarch64 import is_aarch64
import pyds
```
The sample applications gets the import path for this module through common/utils.py. A setup.py is also included for installing the module into standard path:
cd /opt/nvidia/deepstream/deepstream/lib
python3 setup.py install

This is currently not automatically done through the SDK installer because python usage is optional.

The bindings generally follow the same API as the underlying C/C++ library, with a few exceptions detailed in sections below.

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This repository contains Python bindings and sample applications for the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk).

The bindings and apps are currently in *Alpha* at v0.9. The API is maturing but changes are still expected.
SDK version supported: 5.0 Developer Preview
SDK version supported: 5.0

Download the latest release package complete with bindings and sample applications from the [release section](../../releases).

Expand All @@ -16,7 +15,7 @@ Please report any issues or bugs on the [Deepstream SDK Forums](https://devtalk.
## Python Bindings

DeepStream pipelines can be constructed using Gst Python, the GStreamer framework's Python bindings. For accessing DeepStream MetaData,
Python bindings are provided in the form of a compiled module. Download these bindings [here](https://developer.nvidia.com/deepstream-download#python_bindings). This module is generated using [Pybind11](https://github.com/pybind/pybind11).
Python bindings are provided in the form of a compiled module which is included in the DeepStream SDK. This module is generated using [Pybind11](https://github.com/pybind/pybind11).

<p align="center">
<img src=".python-app-pipeline.png" alt="bindings pipeline" height="600px"/>
Expand Down
25 changes: 15 additions & 10 deletions apps/README
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ Package Contents
--------------------------------------------------------------------------------
The DeepStream Python package includes:
1. Python bindings for DeepStream Metadata libraries
These bindings are provided as a compiled module, available for
x86_64 and Jetson platforms. Find them at:
bindings
|- x86_64
| |- pyds.so
|- jetson
|- pyds.so
These bindings are installed as part of the SDK at:
/opt/nvidia/deepstream/deepstream/lib/pyds.so

Sample applications that import is_aarch_64 automatically
have this path added.

A setup.py is also provided to install this extension into standard path.
Currently this needs to be run manually:
$ cd /opt/nvidia/deepstream/deepstream/lib
$ python3 setup.py install

2. DeepStream test apps in Python
The following test apps are available:
deepstream-test1
Expand Down Expand Up @@ -75,10 +79,11 @@ $ sudo apt install python3-gi python3-dev python3-gst-1.0 -y
Running the samples
--------------------------------------------------------------------------------
The apps are configured to work from inside the DeepStream SDK 5.0 installation.
Untar the contents into <DeepStream install root>/sources/.

Note that the apps import the pyds module from this relative path:
../bindings/<platform>
Clone the deepstream_python_apps repo under <DeepStream 5.0 ROOT>/sources:
$ git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
This will create the following directory:
<DeepStream 5.0 ROOT>/sources/deepstream_python_apps

Follow README in each app's directory to run the app.

Expand Down
3 changes: 1 addition & 2 deletions apps/common/is_aarch_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
def is_aarch64():
return platform.uname()[4] == 'aarch64'


sys.path.append('../../bindings/' + ('jetson' if is_aarch64() else 'x86_64'))
sys.path.append('/opt/nvidia/deepstream/deepstream/lib')
2 changes: 2 additions & 0 deletions apps/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
################################################################################

import ctypes
import sys
sys.path.append('/opt/nvidia/deepstream/deepstream/lib')

def long_to_int(l):
value = ctypes.c_int(l & 0xffffffff).value
Expand Down
33 changes: 31 additions & 2 deletions apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# num-detected-classes
#
# Optional properties for detectors:
# enable-dbscan(Default=false), interval(Primary mode only, Default=0)
# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0)
# custom-lib-path
# parse-bbox-func-name
#
Expand All @@ -51,7 +51,7 @@
# Other optional properties:
# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32),
# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path,
# mean-file, gie-unique-id(Default=0), offsets, gie-mode (Default=1 i.e. primary),
# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary),
# custom-lib-path, network-mode(Default=0 i.e FP32)
#
# The values in the config file are overridden by values set through GObject
Expand All @@ -62,8 +62,10 @@ gpu-id=0
net-scale-factor=0.0039215697906911373
model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel
proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
labelfile-path=../../../../samples/models/Primary_Detector/labels.txt
int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
force-implicit-batch-dim=1
batch-size=1
process-mode=1
model-color-format=0
Expand All @@ -79,3 +81,30 @@ cluster-mode=1
threshold=0.2
eps=0.7
minBoxes=1

#Use the config params below for dbscan clustering mode
[class-attrs-all]
detected-min-w=4
detected-min-h=4
minBoxes=3

## Per class configurations
[class-attrs-0]
pre-cluster-threshold=0.05
eps=0.7
dbscan-min-score=0.95

[class-attrs-1]
pre-cluster-threshold=0.05
eps=0.7
dbscan-min-score=0.5

[class-attrs-2]
pre-cluster-threshold=0.1
eps=0.6
dbscan-min-score=0.95

[class-attrs-3]
pre-cluster-threshold=0.05
eps=0.7
dbscan-min-score=0.5
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion apps/deepstream-ssd-parser/README
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,26 @@ This example:
- Encodes OSD output and saves to MP4 file. Note that there is no visual output on screen.

Known Issue:
On Jetson, if libgomp is not preloaded, this error may occur:
1. On Jetson, if libgomp is not preloaded, this error may occur:
(python3:21041): GStreamer-WARNING **: 14:35:44.113: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstlibav.so': /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block
Unable to create Encoder

2. On Jetson Nano, ssd_inception_v2 is not expected to run with GPU instance.
Switch to CPU instance when running on Nano:
update config.pbtxt files in samples/trtis_modeo_repo:
# Switch to CPU instance for Nano since memory might not be enough for
# certain Models.

# Specify CPU instance.
instance_group {
count: 1
kind: KIND_CPU
}

# Specify GPU instance.
#instance_group {
# kind: KIND_GPU
# count: 1
# gpus: 0
#}

2 changes: 1 addition & 1 deletion apps/deepstream-ssd-parser/dstest_ssd_nopostprocess.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ infer_config {
model_repo {
root: "../../../../samples/trtis_model_repo"
log_level: 2
tf_gpu_memory_fraction: 0.6
tf_gpu_memory_fraction: 0.4
tf_disable_soft_placement: 0
}
}
Expand Down
11 changes: 7 additions & 4 deletions apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# num-detected-classes
#
# Optional properties for detectors:
# enable-dbscan(Default=false), interval(Primary mode only, Default=0)
# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0)
# custom-lib-path,
# parse-bbox-func-name
#
Expand All @@ -51,7 +51,7 @@
# Other optional properties:
# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32),
# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path,
# mean-file, gie-unique-id(Default=0), offsets, gie-mode (Default=1 i.e. primary),
# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary),
# custom-lib-path, network-mode(Default=0 i.e FP32)
#
# The values in the config file are overridden by values set through GObject
Expand All @@ -61,18 +61,21 @@
gpu-id=0
net-scale-factor=0.0039215697906911373
model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
labelfile-path=../../../../samples/models/Primary_Detector/labels.txt
int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
force-implicit-batch-dim=1
batch-size=1
network-mode=1
num-detected-classes=4
interval=0
gie-unique-id=1
output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid
#scaling-filter=0
#scaling-compute-hw=0

[class-attrs-all]
threshold=0.2
pre-cluster-threshold=0.2
eps=0.2
group-threshold=1
2 changes: 1 addition & 1 deletion apps/deepstream-test1-usbcam/README
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Example:
This document shall describe the sample deepstream-test1-usb application.

It is meant for simple demonstration of how to use the various DeepStream SDK
elements in the pipeline and extract meaningful insights from a video stream.
elements in the pipeline and extract meaningful insights from a usb camera stream.

This sample creates instance of "nvinfer" element. Instance of
the "nvinfer" uses TensorRT API to execute inferencing on a model. Using a
Expand Down
11 changes: 7 additions & 4 deletions apps/deepstream-test1-usbcam/dstest1_pgie_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# num-detected-classes
#
# Optional properties for detectors:
# enable-dbscan(Default=false), interval(Primary mode only, Default=0)
# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0)
# custom-lib-path,
# parse-bbox-func-name
#
Expand All @@ -51,7 +51,7 @@
# Other optional properties:
# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32),
# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path,
# mean-file, gie-unique-id(Default=0), offsets, gie-mode (Default=1 i.e. primary),
# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary),
# custom-lib-path, network-mode(Default=0 i.e FP32)
#
# The values in the config file are overridden by values set through GObject
Expand All @@ -61,18 +61,21 @@
gpu-id=0
net-scale-factor=0.0039215697906911373
model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
labelfile-path=../../../../samples/models/Primary_Detector/labels.txt
int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
force-implicit-batch-dim=1
batch-size=1
network-mode=1
num-detected-classes=4
interval=0
gie-unique-id=1
output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid
#scaling-filter=0
#scaling-compute-hw=0

[class-attrs-all]
threshold=0.2
pre-cluster-threshold=0.2
eps=0.2
group-threshold=1
5 changes: 4 additions & 1 deletion apps/deepstream-test1/dstest1_pgie_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt
model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
labelfile-path=../../../../samples/models/Primary_Detector/labels.txt
int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
force-implicit-batch-dim=1
batch-size=1
network-mode=1
num-detected-classes=4
interval=0
gie-unique-id=1
output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid
#scaling-filter=0
#scaling-compute-hw=0

[class-attrs-all]
threshold=0.2
pre-cluster-threshold=0.2
eps=0.2
group-threshold=1
Loading

0 comments on commit 971626b

Please sign in to comment.