Showing posts with label NVIDIA. Show all posts
Showing posts with label NVIDIA. Show all posts

Sunday, 14 March 2021

Running NVIDIA DIGITS Docker container on Ubuntu

Installing NVIDIA DIGITS directly on your computer means that you'll:
  • spend a considerable amount of time in installing all dependencies and building DIGITS itself
  • pollute your machine with another application and its dependencies
To prevent this, we can run NVIDIA DIGITS Docker container. Let's check first whether docker is installed and its version :

$ docker --version
Docker version 20.10.3, build 48d30b5

For the reference, I was running the commands I listed below in this article on my Ubuntu 20.04:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

Ideally, we'd be running NVIDIA Digits on a machine with GPU(s). This would speed up training and inference but Digits can also work on a machine which has a CPU only. 

I have GeForce GT 640 graphics card:

$ nvidia-smi -L
GPU 0: GeForce GT 640 (UUID: GPU-f2583df9-404d-2564-d332-e7878a94d087)

$ lspci
...
VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 640 OEM] (rev a1)
...

GK107 is a code name for GeForce GT 640 (GDDR5) (source: GeForce 600 series - Wikipedia) which, according to CUDA GPUs | NVIDIA Developer, has computing capability 3.5 (which is supported as it has to be >2.1 according to Installation Guide — NVIDIA Cloud Native Technologies documentation).

To test the local GPU we can run nvidia-smi application on the local host or in Docker image.

If we haven't installed CUDA or nvidia-smi locally, we can run nvidia-smi from NVIDIA CUDA Docker image:

$ sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
Thu Feb 11 01:02:09 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GT 640      Off  | 00000000:01:00.0 N/A |                  N/A |
| 40%   31C    P8    N/A /  N/A |    286MiB /  1992MiB |     N/A      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+


Let's now follow the instructions from DIGITS | NVIDIA NGC. We first need to download the image to our local host:

$ docker pull nvcr.io/nvidia/digits:20.12-tensorflow-py3
20.12-tensorflow-py3: Pulling from nvidia/digits
6a5697faee43: Pulling fs layer 
ba13d3bc422b: Pulling fs layer 
...
cec6045b0d0e: Pulling fs layer 
cb4aa708e833: Waiting 
235cfa23a5f4: Waiting 
24781a3c82ea: Waiting 
f7c7d47c1a97: Pull complete 
...
b57dde2f2923: Pull complete 
Digest: sha256:7542143bc2292fc48a3874786877815a5ca6a74a69366324aaf66914155cb5a7
Status: Downloaded newer image for nvcr.io/nvidia/digits:20.12-tensorflow-py3
nvcr.io/nvidia/digits:20.12-tensorflow-py3

Let's now run the container. docker run has --gpus option which instructs Docker to add GPU devices to container ('all' to pass all GPUs).

$ docker run --gpus all -it --rm nvcr.io/nvidia/digits:20.12-tensorflow-py3
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].

I haven't installed NVIDIA Container Toolkit (nvidia-docker) which enable Docker containers accessing host's GPU. Installation Guide — NVIDIA Cloud Native Technologies documentation describes how to install it:

$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
   && curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
   && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
$ sudo apt-get update
$ sudo apt-get install -y nvidia-docker2
$ sudo systemctl restart docker


nvidia-docker version 
NVIDIA Docker: 2.5.0
Client: Docker Engine - Community
 Version:           20.10.3
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        48d30b5
 Built:             Fri Jan 29 14:33:21 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.3
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       46229ca
  Built:            Fri Jan 29 14:31:32 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


To be on the safe side, I also installed the latest NVIDIA driver.

$ sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
[sudo] password for bojan: 
Thu Feb 11 01:02:09 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GT 640      Off  | 00000000:01:00.0 N/A |                  N/A |
| 40%   31C    P8    N/A /  N/A |    286MiB /  1992MiB |     N/A      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+


This time running DIGITS container was successful. DIGITS 6.0 http server uses port 5000 by default and in this example it is mapped to host port 8888.

$ docker run --gpus all -it --rm -p 8888:5000 nvcr.io/nvidia/digits:20.12-tensorflow-py3

============
== DIGITS ==
============

NVIDIA Release 20.12 (build 17912121)
DIGITS Version 6.1.1

Container image Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
DIGITS Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved.

Various files include modifications (c) NVIDIA CORPORATION.  All rights reserved.
NVIDIA modifications are covered by the license terms that apply to the underlying project or file.
ERROR: No supported GPU(s) detected to run this container

  ___ ___ ___ ___ _____ ___
 |   \_ _/ __|_ _|_   _/ __|
 | |) | | (_ || |  | | \__ \
 |___/___\___|___| |_| |___/ 6.1.1

Caffe support disabled.
Reason: A valid Caffe installation was not found on your system.
cudaRuntimeGetVersion() failed with error #999
2021-02-11 16:23:54.454747: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
/opt/digits/digits/pretrained_model/views.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if str(files['weights_file'].filename) is '':
/opt/digits/digits/pretrained_model/views.py:38: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if str(files['model_def_file'].filename) is '':
/opt/digits/digits/pretrained_model/views.py:54: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if str(files['weights_file'].filename) is '':
/opt/digits/digits/pretrained_model/views.py:60: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if str(files['model_def_file'].filename) is '':
/opt/digits/digits/pretrained_model/views.py:169: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif str(flask.request.form['job_name']) is '':
/opt/digits/digits/pretrained_model/views.py:177: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if str(flask.request.files['labels_file'].filename) is not '':
2021-02-11 16:23:56 [INFO ] Loaded 0 jobs.


If we now open a browser on the host and type http://localhost:8888 we'll be able to see DIGITS home page:



As DIGITS is a web-based application we don't need to run it in interactive mode (docker run -it) but can run it in a detached mode (docker run -d):

$ docker run \
--gpus all \
-d \
--name digits \
--rm \
-p 8888:5000 \
-v /home/bojan/dev/digits-demo/data:/data \
-v /home/bojan/dev/digits-demo/jobs:/workspace/jobs \ nvcr.io/nvidia/digits:20.12-tensorflow-py3

905f9a8c8e48bc87ae99117eed92b855d45c7d37695c0e94433bd18fab6bfaca

We can verify that DIGITS container is indeed running:

$ docker ps 
CONTAINER ID   IMAGE                                        COMMAND                  CREATED              STATUS              PORTS                                                  NAMES
905f9a8c8e48   nvcr.io/nvidia/digits:20.12-tensorflow-py3   "/usr/local/bin/nvid…"   About a minute ago   Up About a minute   6006/tcp, 6064/tcp, 8888/tcp, 0.0.0.0:8888->5000/tcp   digits


Why DIGITS doesn't recognize my GPU?



One thing didn't seem right to me though. In the upper right corner of the DIGITS home page should be a text which indicates how many GPUs are available. In my case, although I have one GPU, no GPUs were listed. 




I tried first to check if GPU is indeed visible from the container:

$ docker exec -it digits bash
root@e58b860504a9:/workspace# 

root@e58b860504a9:/workspace# nvidia-smi
Fri Feb 12 23:33:17 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GT 640      Off  | 00000000:01:00.0 N/A |                  N/A |
| 40%   32C    P8    N/A /  N/A |    260MiB /  1992MiB |     N/A      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Graphics card was visible. DIGITS installation contains a Python script which is DIGITS Device Query (source code: python/9427/DIGITS/digits/device_query.py). When I tried to run it, I got an error:

root@e58b860504a9:/opt/digits/digits# python device_query.py 
cudaRuntimeGetVersion() failed with error #999
No devices found.


cudaErrorUnknown = 999
This indicates that an unknown internal error has occurred.
CUDA was installed fine:

root@6cd6c429f20c:/workspace# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0


On the host system I checked if loading the NVIDIA driver gave any errors (NVRM errors are internal to the nvidia kernel module):

$ sudo dmesg |grep NVRM
[sudo] password for bojan: 
[    2.283911] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  460.32.03  Sun Dec 27 19:00:34 UTC 2020
[ 8654.742795] NVRM: GPU at PCI:0000:01:00: GPU-f2583df9-404d-2564-d332-e7878a94d087
[ 8654.742800] NVRM: Xid (PCI:0000:01:00): 31, pid=577, Ch 00000002, intr 10000000. MMU Fault: ENGINE HOST4 HUBCLIENT_HOST faulted @ 0x1_01160000. Fault is of type FAULT_INFO_TYPE_UNSUPPORTED


I could not deduct anything useful from here but by reading DIGITS release notes I finally found the reason why DIGITS won't recognize my GPU - it is too old!

Installation Guide — NVIDIA Cloud Native Technologies documentation specifies compute capability requirements for NVIDIA Container Toolkit but compute capability requirements for DIGITS Docker image are specified for each image release. For digits:20.12 DIGITS Release Notes :: NVIDIA Deep Learning DIGITS Documentation states the following:

Release 20.12 supports CUDA compute capability 6.0 and higher.

My GPU has compute capability 3.5 and so it does not meet that requirement.


References







Sunday, 10 January 2021

Installing JetPack on Jetson TX2 from NVIDIA SDK Manager Docker container

For a very long time, if you wanted to flash your Jetson TX and install JetPack SDK you had to download and install NVIDIA JetPack and later, NVIDIA SDK Manager, on the Linux host computer first. Every package installation pollutes your host machine and also takes some disk space. To avoid this, NVIDA created a Docker image with SDK Manager so once JetPack is installed on Jetson, this Docker image can be deleted and your Linux host remains in the same state as before. This has been available since NVIDIA SDK Manager 1.4 (December 2020).

I had some of the older versions of JetPack installed on my Jetson TX2 and I wanted to install the most recent one (4.4.1 at the moment; 4.5 is announced for January 2021). One of the benefits I wanted to get is the upgrading to the next JetPack release via apt package management tool (this has been available since JetPack 4.4).

I want to share here my experience with the process of running NVIDIA SDK Manager Docker container and flashing the Jetson TX2 with it. I followed the official documentation about this process: Docker Images :: NVIDIA SDK Manager Documentation.

I logged in to NVIDIA Developer center and downloaded this Docker image from this URL: https://developer.nvidia.com/nvidia-sdk-manager-docker-image. The image came as an 942MB archive named sdkmanager-1.4.0.7363_docker.tar.gz.

$ docker load -i ./sdkmanager-1.4.0.7363_docker.tar.gz 
805802706667: Loading layer  65.61MB/65.61MB
3fd9df553184: Loading layer  15.87kB/15.87kB
7a694df0ad6c: Loading layer  3.072kB/3.072kB
2f694c79b042: Loading layer  148.2MB/148.2MB
26765aed7e25: Loading layer  502.3kB/502.3kB
b398b8335e67: Loading layer  6.015MB/6.015MB
08b68150484c: Loading layer  1.135MB/1.135MB
31fbfacf550e: Loading layer  1.135MB/1.135MB
84979f95b15f: Loading layer  502.3kB/502.3kB
cd9205d2e1f9: Loading layer  2.075MB/2.075MB
414d8a00c66e: Loading layer  66.07MB/66.07MB
cc3271f36011: Loading layer  84.83MB/84.83MB
5072b3ebcb77: Loading layer  2.108MB/2.108MB
38be13d541b9: Loading layer  1.781MB/1.781MB
ff63398d24ea: Loading layer  99.17MB/99.17MB
7cb4d04a8659: Loading layer [==================================================>]  462.3MB/462.3MB
cd2c9f6e22b0: Loading layer [==================================================>]  2.048kB/2.048kB
65cd593db96f: Loading layer [==================================================>]  3.584kB/3.584kB
8900dbcf5626: Loading layer [==================================================>]  3.584kB/3.584kB
9ac46abadb31: Loading layer [==================================================>]  3.072kB/3.072kB
a20c9aaeb9c3: Loading layer [==================================================>]  417.3kB/417.3kB
cae1bf65143a: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: sdkmanager:1.4.0.7363

As this is the latest version of this Docker image, I tagged it with the latest tag:

$ docker tag sdkmanager:1.4.0.7363 sdkmanager:latest

I made sure that the image is listed among other Docker images on my machine:

$ docker images  
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
sdkmanager              1.4.0.7363          0e9d62e318ad        2 weeks ago         913MB
sdkmanager              latest              0e9d62e318ad        2 weeks ago         913MB
...

SDK Manager executable (sdkmanager) is the entrypoint of this Docker image and I wanted to test the Docker image by running it with some simple CLI commands listed here.

$ docker run -it --rm sdkmanager --help

NVIDIA SDK MANAGER

  NVIDIA SDK Manager is an all-in-one tool that bundles developer software and
  provides an end-to-end development environment setup solution for NVIDIA
  SDKs.

General Options

  -h, --help                             Displays this usage guide.
  --ver                                  Output the version of the installed SDK Manager client
  --settings                             Optional. Configure SDK Manager settings in the terminal.
  --query interactive|noninteractive     Prints all options available for the user. Must be executed with the --use or --offline settings
  --showallversions                      Prints all available product versions for the user.
  --logs                                 Optional. Set this option to export the log files when the process is complete.
  --exitonfinish                         Optional. Automatically exit from SDK Manager when the install/uninstall session is finished (skip user input). Intended for scripts/automation usage.
  --user email_address                   Optional. Set the user email to login. Valid only for NVOnline login.
  --password string                      Optional. Set the user login password. Valid only for NVOnline login.
  --logintype devzone|nvonline           Optional. Login with developer.nvidia.com or partners.nvidia.com account. Default is devzone.
  --staylogin true|false                 Optional. Keep the user account logged-in for next running session.
  --logout                               Logout user account from SDK Manager.
  --offline                              Optional. Skip login to NVIDIA servers. Install SDK from pre downloaded location, used with --downloadfolder option.
  --downloadfolder string                Optional. Set the download folder for the SDK components. Used for downloading the files and for locating the SDK components when using --offline.
  --archivedversions                     Optional. Display only archived versions.
  --cli install|uninstall|downloadonly   Mandatory. Set the requested action.
  --sudopassword string                  Optional. Set the sudo password to skip the authentication prompt.
  --datacollection enable|disable        Optional. Set to enable or disalbe usage data collection.

Specific arguments for install/uninstall:

  --product product_name                 Mandatory. Set the product name.
  --version string                       Mandatory. Set the product version. Use --query to get available version values.
  --targetos target_os                   Mandatory. Set the target hardware operating system.
  --host                                 Optional. Set if host side components need to be installed.
  --target target_hardware               Optional. Set the target hardware in use. Use hardware code name.
  --flash all|a|b|ab|skip                Optional. Set the flash operation mode, which of the Tegras should be flashed.
  --additionalsdk additional_sdk_title   Optional. Specify any additional SDK to install. Multiple entries are allowed.
  --select section_or_group_title        Optional. Specify section or group to installation list. Multiple entries are allowed.
  --deselect section_or_group_title      Optional. Specify section or group to exclude from installation list. Multiple entries are allowed.
  --license accept                       Optional. Set this option to accept the terms and conditions of SDK license agreements.
  --targetimagefolder string             Optional. Set the host location of the target hardware image for flashing.
  --responsefile string                  Optional. Set the response file path. Response file samples can be found in the product folder /opt/nvidia/sdkmanager.

Example

  $ sdkmanager [--user user@user.com] [--query]
  $ sdkmanager [--cli install|uninstall|downloadonly] [cli options] ...
  $ sdkmanager [--settings]
  $ sdkmanager [--help]                                        

$ docker run -it --rm sdkmanager --ver
1.4.0.7363

I connected Jetson TX2 to my Ubuntu host via USB cable and put Jetson into forced recovery mode (as described here: Jetson_X2_Developer_Kit_User_Guide.pdf).

I checked that Jetson is listed among other USB devices:

$ lsusb
...
Bus 002 Device 004: ID 0955:7c18 NVIDIA Corp. APX
...

I then run a query command on SDK manager to get a list of available install options:

$ docker run -it --rm sdkmanager --query
To initiate login process open https://static-login.nvidia.com/service/default/pin?user_code=36223035 in a browser (can be done on a different machine) and login with your NVIDIA Developer account. SDK Manager will start once done.
Login user code: 36223035. (valid for: 10 minutes).
? SDK Manager is waiting for you to complete login. 
  1) Generate a new login user code
  2) Cancel login
  Answer: 
Waiting for user information from NVIDIA authentication server...
Retrieving user information...
Loading and processing available products...
Login succeeded.
Loading user information...
User information loaded successfully.
Loading server data...
Server data loaded successfully.
Available options are:

 Jetson 4.4
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P2888-0001 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P2888-0004 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P2888-0006 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P2888-0060 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3668-0000 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3668-0001 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3310-1000 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3489-0080 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3489-0888 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3489-0000 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P2180-1000 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3448-0000 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3448-0002 --flash all --additionalsdk DeepStream
sdkmanager --cli install --logintype devzone --product Jetson --version 4.4 --targetos Linux --host --target P3448-0020 --flash all --additionalsdk DeepStream


Query completed.

I was not sure which target I should choose so I used table from NVIDIA Jetson Linux Developer Guide : Introduction | NVIDIA Docs to check the P-number of my Jetson TX2 and it was P3310-1000.

It was now the time to do the main part of the job. As a guide, I looked at the docker run command example used for flashing Jetson Nano (listed here: Docker Images :: NVIDIA SDK Manager Documentation) and modified it for Jetson TX2:

$ docker run -it --rm --privileged -v /dev/bus/usb:/dev/bus/usb/ --name JetPack_TX2_Devkit sdkmanager --cli install --logintype devzone --product Jetson --target P3310-1000 --targetos Linux --version 4.4.1 --flash all --license accept --staylogin true --datacollection enable --exitonfinish
To initiate login process open https://static-login.nvidia.com/service/default/pin?user_code=64552553 in a browser (can be done on a different machine) and login with your NVIDIA Developer account. SDK Manager will start once done.
Login user code: 61234563. (valid for: 10 minutes).
? SDK Manager is waiting for you to complete login. 
  1) Generate a new login user code
  2) Cancel login
  Answer: 
Waiting for user information from NVIDIA authentication server...
Retrieving user information...
Loading and processing available products...
Login succeeded.
Loading user information...
User information loaded successfully.
Loading server data...
Server data loaded successfully.
Session initialized...

Installation of this software is under the terms and conditions of the license agreements located in /opt/nvidia/sdkmanager/Eula/
  ===== INSTALLATION COMPLETED SUCCESSFULLY. ===== 
      - Drivers for Jetson: Installed
      - File System and OS: Installed
      - Device Mode Host Setup in Flash: Installed
      - Flash Jetson TX2: Installed
      - Device Mode Host Setup in Target SDK: Installed
      - DateTime Target Setup: Installed
      - CUDA Toolkit for L4T: Installed
      - cuDNN on Target: Installed
      - TensorRT on Target: Installed
      - OpenCV on Target: Installed
      - VisionWorks on Target: Installed
      - VPI on Target: Installed
      - NVIDIA Container Runtime with Docker integration (Beta): Installed
      - Multimedia API: Installed

  ===== Installation completed successfully - Total 14 components =====
  ===== 14 succeeded, 0 failed, 0 up-to-date, 0 skipped =====



Here are some screenshots of the SDK manager running from within Docker container which show the process of downloading the packages, flashing the OS and installing JetPack on Jetson board:



















Upon flashing the Jetson, L4T (Linux 4 Tegra) Ubuntu flavor setup appears:




...and after some typical Ubuntu setup steps, we can see something like this:


...and the final look of the desktop:


Monday, 23 December 2019

How to install TensorRT Python package on NVIDIA Jetson Nano

Source code of the following Python script contains:

import tensorrt as trt

...and its execution fails:


(tensorflow-demo) nvidia@nvidia-nano:~/dev/nvidia/uff_ssd$ python detect_objects.py images/image1.jpg
Traceback (most recent call last):
  File "detect_objects.py", line 58, in <module>
    import tensorrt as trt
ModuleNotFoundError: No module named 'tensorrt'

TensorRT Pyton module was not installed. I want to share here my experience with the process of setting up TensorRT on Jetson Nano as described here:
A Guide to using TensorRT on the Nvidia Jetson Nano - Donkey Car

$ sudo find / -name nvcc
[sudo] password for nvidia:
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/120/gvfs’: Permission denied
/usr/local/cuda-10.0/bin/nvcc
/home/nvidia/.cache/bazel/_bazel_nvidia/0c75cc683915a1db7f4f8a4da90fb148/execroot/org_tensorflow/bazel-out/host/bin/external/local_config_cuda/cuda/cuda/bin/nvcc
/home/nvidia/.cache/bazel/_bazel_nvidia/0c75cc683915a1db7f4f8a4da90fb148/execroot/org_tensorflow/bazel-out/aarch64-py2-opt/bin/external/local_config_cuda/cuda/cuda/bin/nvcc
/home/nvidia/.cache/bazel/_bazel_nvidia/0c75cc683915a1db7f4f8a4da90fb148/execroot/org_tensorflow/bazel-out/aarch64-opt/bin/external/local_config_cuda/cuda/cuda/bin/nvcc


nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ /usr/local/cuda-10.0/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Mon_Mar_11_22:13:24_CDT_2019
Cuda compilation tools, release 10.0, V10.0.326


nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ cd /usr/local/cuda

nvidia@nvidia-nano:/usr/local/cuda$ ls
bin  extras   lib64    NsightCompute-1.0  nvvm    samples  targets  version.txt
doc  include  LICENSE  nvml               README  share    tools

nvidia@nvidia-nano:/usr/local/cuda$ cd bin

nvidia@nvidia-nano:/usr/local/cuda/bin$ ls
bin2c     cuda-gdbserver                fatbinary     nvlink
crt       cuda-install-samples-10.0.sh  nvcc          nvprof
cudafe++  cuda-memcheck                 nvcc.profile  nvprune
cuda-gdb  cuobjdump                     nvdisasm      ptxas

nvidia@nvidia-nano:/usr/local/cuda/bin$ ls -la
total 57272
drwxr-xr-x  3 root root     4096 Aug 16 19:42 .
drwxr-xr-x 12 root root     4096 Aug 16 19:43 ..
-rwxr-xr-x  1 root root    60600 Mar 12  2019 bin2c
drwxr-xr-x  2 root root     4096 Aug 16 19:36 crt
-rwxr-xr-x  1 root root  3960000 Mar 12  2019 cudafe++
-rwxr-xr-x  1 root root  6143896 Mar 12  2019 cuda-gdb
-rwxr-xr-x  1 root root   472429 Mar 12  2019 cuda-gdbserver
-rwxr-xr-x  1 root root      784 Mar 12  2019 cuda-install-samples-10.0.sh
-rwxr-xr-x  1 root root   259368 Mar 12  2019 cuda-memcheck
-rwxr-xr-x  1 root root   270128 Mar 12  2019 cuobjdump
-rwxr-xr-x  1 root root   119280 Mar 12  2019 fatbinary
-rwxr-xr-x  1 root root   180816 Mar 12  2019 nvcc
-rw-r--r--  1 root root      393 Mar 12  2019 nvcc.profile
-rwxr-xr-x  1 root root 22607128 Mar 12  2019 nvdisasm
-rwxr-xr-x  1 root root  8979096 Mar 12  2019 nvlink
-rwxr-xr-x  1 root root  6597104 Mar 12  2019 nvprof
-rwxr-xr-x  1 root root    77280 Mar 12  2019 nvprune
-rwxr-xr-x  1 root root  8874104 Mar 12  2019 ptxas

nvidia@nvidia-nano:/usr/local/cuda/bin$ ./nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Mon_Mar_11_22:13:24_CDT_2019
Cuda compilation tools, release 10.0, V10.0.326

nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ sudo gedit ~/.bashrc

# Add this to your .bashrc file
export CUDA_HOME=/usr/local/cuda
# Adds the CUDA compiler to the PATH
export PATH=$CUDA_HOME/bin:$PATH
# Adds the libraries
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH

nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ source ~/.bashrc

nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Mon_Mar_11_22:13:24_CDT_2019
Cuda compilation tools, release 10.0, V10.0.326

Just after I issued pip install pycuda:

nvidia@nvidia-nano:~$ sudo find / -name *pycuda*
[sudo] password for nvidia: 
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/120/gvfs’: Permission denied
/tmp/pip-install-sf96wq0d/pycuda
/tmp/pip-install-sf96wq0d/pycuda/pycuda.egg-info
/tmp/pip-install-sf96wq0d/pycuda/build/lib.linux-aarch64-3.6/pycuda
/tmp/pip-install-sf96wq0d/pycuda/build/lib.linux-aarch64-3.6/pycuda/cuda/pycuda-helpers.hpp
/tmp/pip-install-sf96wq0d/pycuda/build/lib.linux-aarch64-3.6/pycuda/cuda/pycuda-complex.hpp
/tmp/pip-install-sf96wq0d/pycuda/build/lib.linux-aarch64-3.6/pycuda/cuda/pycuda-complex-impl.hpp
/tmp/pip-install-sf96wq0d/pycuda/pycuda
/tmp/pip-install-sf96wq0d/pycuda/pycuda/cuda/pycuda-helpers.hpp
/tmp/pip-install-sf96wq0d/pycuda/pycuda/cuda/pycuda-complex.hpp
/tmp/pip-install-sf96wq0d/pycuda/pycuda/cuda/pycuda-complex-impl.hpp
/tmp/pip-install-sf96wq0d/pycuda/pip-egg-info/pycuda.egg-info
/tmp/pip-install-sf96wq0d/pycuda/bpl-subset/bpl_subset/pycudaboost

Installing pycuda:

(tensorflow-demo) nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ pip install pycuda
Collecting pycuda
  Using cached https://files.pythonhosted.org/packages/5e/3f/5658c38579b41866ba21ee1b5020b8225cec86fe717e4b1c5c972de0a33c/pycuda-2019.1.2.tar.gz
Requirement already satisfied: pytools>=2011.2 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pycuda) (2019.1.1)
Requirement already satisfied: decorator>=3.2.0 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pycuda) (4.4.1)
Requirement already satisfied: appdirs>=1.4.0 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pycuda) (1.4.3)
Requirement already satisfied: mako in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pycuda) (1.1.0)
Requirement already satisfied: six>=1.8.0 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pytools>=2011.2->pycuda) (1.13.0)
Requirement already satisfied: numpy>=1.6.0 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from pytools>=2011.2->pycuda) (1.17.4)
Requirement already satisfied: MarkupSafe>=0.9.2 in /home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages (from mako->pycuda) (1.1.1)
Building wheels for collected packages: pycuda
  Building wheel for pycuda (setup.py) ... done
  Created wheel for pycuda: filename=pycuda-2019.1.2-cp36-cp36m-linux_aarch64.whl size=4497309 sha256=e7bbecd3bfa86a84f2ed505966a51123d97073cb4fd981ed434959f20a7507f3
  Stored in directory: /home/nvidia/.cache/pip/wheels/a6/60/f0/b1c430c73d281ac3e46070480db50f7907364eb6f6d3188396
Successfully built pycuda
Installing collected packages: pycuda
Successfully installed pycuda-2019.1.2

Let's see where is now pycuda:

nvidia@nvidia-nano:~$ sudo find / -name *pycuda*
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/120/gvfs’: Permission denied
/home/nvidia/.cache/pip/wheels/a6/60/f0/b1c430c73d281ac3e46070480db50f7907364eb6f6d3188396/pycuda-2019.1.2-cp36-cp36m-linux_aarch64.whl
/home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages/pycuda-2019.1.2.dist-info
/home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages/pycuda
/home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages/pycuda/cuda/pycuda-helpers.hpp
/home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages/pycuda/cuda/pycuda-complex.hpp
/home/nvidia/python-envs/tensorflow-demo/lib/python3.6/site-packages/pycuda/cuda/pycuda-complex-impl.hpp

Let's find TensorRT:

nvidia@nvidia-nano:~$ ls -la /usr/lib/python3.6/dist-packages
total 4272
drwxrwxr-x 10 root root    4096 Nov 28 22:43 .
drwxr-xr-x 33 root root   20480 Dec  7 23:46 ..
-rw-r--r--  1 root root 2831864 Feb  6  2019 cv2.cpython-36m-aarch64-linux-gnu.so
drwxr-xr-x  2 root root    4096 Aug 16 19:52 graphsurgeon
drwxr-xr-x  2 root root    4096 Aug 16 19:52 graphsurgeon-0.4.1.dist-info
drwxr-xr-x  4 root root    4096 Nov 28 22:43 jetson
drwxr-xr-x  4 root root    4096 Nov 28 22:43 Jetson
-rw-r--r--  1 root root  746496 Nov 28 22:43 jetson_inference_python.so
-rw-r--r--  1 root root  725512 Nov 28 22:43 jetson_utils_python.so
drwxr-xr-x  3 root root    4096 Aug 16 19:52 tensorrt
drwxr-xr-x  2 root root    4096 Aug 16 19:52 tensorrt-5.1.6.1.dist-info
drwxr-xr-x  5 root root    4096 Aug 16 19:52 uff
drwxr-xr-x  2 root root    4096 Aug 16 19:52 uff-0.6.3.dist-info

nvidia@nvidia-nano:~$ ls -la /usr/lib/python3.6/dist-packages/tensorrt
total 2156
drwxr-xr-x  3 root root    4096 Aug 16 19:52 .
drwxrwxr-x 10 root root    4096 Nov 28 22:43 ..
-rw-r--r--  1 root root    2914 Jun  4  2019 __init__.py
drwxr-xr-x  6 root root    4096 Aug 16 19:52 legacy
-rw-r--r--  1 root root 2190376 Jun  4  2019 tensorrt.so


TensorRT is still not visible to Python in virtual environment though:

(tensorflow-demo) nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ python -c "import tensorrt as trt"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorrt'

We need to add the path to TensorRT package to PYTHONPATH in virtual environment:

(tensorflow-demo) nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ export PYTHONPATH=/usr/lib/python3.6/dist-packages:$PYTHONPATH

TensorRT is now visible to Python:

(tensorflow-demo) nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ python -c "import tensorrt as trt"

(tensorflow-demo) nvidia@nvidia-nano:/usr/src/tensorrt/samples/python$ python
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt as trt
>>> trt.__version__
'5.1.6.1'
>>>