Install Deepstream SDK on Nvidia RTX 2060 GPU

Tunggal MAT
Deepstream Tutorial
6 min readApr 28, 2020

What i use in this installation ?

Device : Asus ROG
OS : Ubuntu 18.04
GPU : Nvidia RTX 2060
CUDA : 10.2
CUDNN : 7.6.5
TensorRT : 7.0.0
Deepstream : 4.0.2

Don’t talk too much, let’s do it bro...

First you must have NVIDIA Driver Graphic >= 440 and CUDA Toolkit 10.2 installed on your machine.
If you’ve previous installed driver and CUDA please remove first, so we can start with fresh installation.

Remove Previous Cuda Installation

1. Remove all your CUDA Components that have installed.

sudo apt autoremove — purge ‘cuda*’

2. Remove your previous graphic driver.

sudo apt autoremove — purge ‘*nvidia*’

3. Enabling nouveau driver (default graphic driver) for Ubuntu

echo ‘nouveau’ | sudo tee -a /etc/modules

4. Check if CUDA is completely removed from your machine

dpkg -l | grep cuda

If there is libcudnn still installed, please remove too.

sudo apt autoremove — purge <your_libcudnn_packages>

5. Check if your graphic also removed

dpkg -l | grep nvidia

6. Clean all broken dependencies

sudo apt autoremove

7. Reboot your machine

sudo reboot

Install Cuda 10.2

source : https://medium.com/@sh.tsang/tutorial-cuda-v10-2-cudnn-v7-6-5-installation-ubuntu-18-04-3d24c157473f

After clean all NVIDIA components, let’s install the new graphic driver and CUDA Toolkit.

1. Download CUDA Toolkit 10.2 + NVIDIA Graphic driver 440.33 from NVIDIA Downloads Page.

wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run

2. Make sure your machine if up-to-date. You can use following command for updating your machine.

sudo apt update
sudo apt upgrade

3. Disable noveau driver (avoiding graphic driver installation error). Create new file with nano editor on /etc/modprobe.d/blacklist-nouveau.conf.

sudo nano /etc/modprobe.d/blacklist-nouveau.conf

4. Enter following content into it.

blacklist nouveau
options nouveau modeset=0

5. Regenerate kernel initramfs

sudo update-initramfs -u

6. Now, reboot:

sudo reboot

7. After rebooting, Go to Downloads directory, then install it

cd ~/Downloads
sudo sh cuda_10.2.89_440.33.01_linux.run

8. Then choose accept, then select all following package will be installed, or you can unselect optional package such as sample, demo, and documentation. Then choose install

Got some error in this step ? check the installation log

cat /var/log/cuda-installer.log

If the error is like this : [ERROR]: Install of driver component failed.
open nvidia-installer log

/var/log/nvidia-installer.log

9. If you found error on nvidia-installer.log like this ‘Kernel module load error: Operation not permitted’. It means your machine is secured with secure boot. The solution for this problem you can goto this link https://askubuntu.com/questions/1048135/how-can-i-install-nvidia-drivers-on-ubuntu-18-04-with-secure-boot

10. After installation, usually your machine will reboot and when you first boot after installation, you will asked for entering MOK Key. This key is required for NVIDIA Graphic driver loading in secure boot and run in your startup. Attention, don’t miss it.

11. check if NVIDIA Driver have installed with command

nvidia-smi

The result should be like this

12. After that, please enter step 7–8. On step 8, unchecked NVIDIA Driver because you’ve already have one from step 9.

13. After instalation done edit the ~/.bashrc.

sudo gedit ~/.bashrc

14. Add the following to the end of file:

export PATH=/usr/local/cuda/bin:$PATH 
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

15. Run the ~/.bashrc again.

source ~/.bashrc

16. Verify CUDA Toolkit installation with

nvcc -V

The result should be like this

Install cuDNN v7.6.5

source : https://medium.com/@sh.tsang/tutorial-cuda-v10-2-cudnn-v7-6-5-installation-ubuntu-18-04-3d24c157473f

1. Go to NVIDIA website and Login NVIDIA Developer Account

2. Goto https://developer.nvidia.com/rdp/cudnn-download

3. Choose installer Download cuDNN v7.6.5 (November 18th, 2019), for CUDA 10.2

4. Download this 3 files :

5. Go to Downloads directory than run :

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
sudo dpkg -i libcudnn7-doc_7.6.5.32–1+cuda10.2_amd64.deb

*if error when execute command dpkg, please re write manually on your terminal, dont copy

6. To verify, copy the sample files to :

cp -r /usr/src/cudnn_samples_v7/ ~

7. Then change the directory:

cd ~/cudnn_samples_v7/mnistCUDNN

8. Make :

make clean && make

9. Test if your instalation is success:

./mnistCUDNN

There will be classification results, and say:

Test passed!

Install TensorRT 7.0

source : https://docs.nvidia.com/deeplearning/sdk/tensorrt-install-guide/index.html#installing-debian

1. Go to NVIDIA website and Login NVIDIA Developer Account

2. Goto https://developer.nvidia.com/nvidia-tensorrt-7x-download

3. Choose instaler TensorRT 7.0.0.11 for Ubuntu 1804 and CUDA 10.2 DEB local repo packages

4. Goto download directory, and install tensorRT with following commands (*if error when execute command dpkg, please re write manually on your terminal, dont copy)

os=”ubuntu1804"
tag=”cuda10.2-trt7.0.0.11-ga-20191216"
sudo dpkg -i nv-tensorrt-repo-${os}-${tag}_1–1_amd64.deb
sudo apt-key add /var/nv-tensorrt-repo-${tag}/7fa2af80.pub
sudo apt-get update
sudo apt-get install tensorrt
sudo apt-get install python-libnvinfer-dev
sudo apt-get install python3-libnvinfer-dev
sudo apt-get install uff-converter-tf

5. Check if TensorRT successfully installed.

dpkg -l | grep TensorRT

And the result should be like this, bro :

Install Deepstream 4.0

source : https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/index.html

1. Remove previous deepstream installation (*if you have):

sudo rm -rf /usr/local/deepstream /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libnvdsgst_* /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstnv* /usr/bin/deepstream* /usr/lib/x86_64-linux-gnu/libv4l/plugins/libcuvidv4l2_plugin.so

2. install the necessary packages before installing the DeepStream SDK:

sudo apt install \
libssl1.0.0 \
libgstreamer1.0–0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libgstrtspserver-1.0–0 \
libjansson4

3. install librdkafka (to enable Kafka protocol adaptor for message broker)
Clone the librdkafka repository from GitHub:

git clone https://github.com/edenhill/librdkafka.git

4. Configure and build

cd librdkafka
git reset — hard 7101c2310341ab3f4675fc565f64f0967e135a6a
./configure
make
sudo make install

5. Copy the generated libraries to the deepstream directory:

sudo mkdir -p /opt/nvidia/deepstream/deepstream-4.0/lib 
sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-4.0/lib

To install the DeepStream SDK, i am using the DeepStream Debian package. So, download the DeepStream 4.0 dGPU Debian package https://developer.nvidia.com/deepstream-download . Choose the DeepStream 4.0.2 for T4 and V100. Choose Download .deb.

If we install the DeepStream SDK Debian package using the dpkg command, we must install these packages first, then install the DeepStream deb package:

sudo apt-get install libgstrtspserver-1.0–0
sudo apt-get install libgstreamer-plugins-base1.0-dev

6. Then enter the FINAL command :

sudo apt-get install ./deepstream-4.0_4.0.2–1_amd64.deb

7. for verify installation, Goto samples config directory, usually in /opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/

deepstream-app -c <path_to_config_file>

8. Viola and your deepstream installation has done

Installing Python Binding for Deepstream

This step required for customize deepstream pipeline using Python language.
references https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/blob/master/HOWTO.md

1. Download python binding in https://developer.nvidia.com/deepstream-getting-started

2. Install depedencies (please deactivate conda environment first)

You can refer to this website to see gst-python Installation http://lifestyletransfer.com/how-to-install-gstreamer-python-bindings/

cd ~
sudo apt-get install python-gi-dev
sudo apt-get install python3-gi python-gst-1.0
sudo apt-get install libgirepository1.0-dev
sudo apt-get install libcairo2-dev gir1.2-gstreamer-1.0
export GST_LIBS=”-lgstreamer-1.0 -lgobject-2.0 -lglib-2.0"
export GST_CFLAGS=”-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include”
git clone https://github.com/GStreamer/gst-python.git
cd gst-python
git checkout 1a8f48a
export PYTHON=/usr/bin/python3
pip3 install pycairo
pip3 install PyGObject
./autogen.sh — disable-gtk-doc — noconfigure
./configure — with-libpython-dir=/usr/lib/x86_64-linux-gnu
make
sudo make install

3. Check the installation.

Go to /opt/nvidia/deepstream/deepstream/sources/python/apps/deepstream-test1

cd /opt/nvidia/deepstream/deepstream/sources/python/apps/deepstream-test1

Run the application

python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264 

OK, Success brother ?

If you got some error, don’t be shy to ask www.google.om , and remember

The greatest mistake is to imagine that we never err. -Thomas Carlyle -

NOTE : I am not responsible if something bad happens to your device after follow this tutorial. Do With Your Own Risk

Thanks…

--

--