1/17/2019

Nvidia 개발환경-Nsight Tools (JetPack 3.3)

1. Nvidia의 Nsight 기본소개  

Nsight는 NVIDIA에서 제공하는 IDE Development Tool로 손쉽게 개발환경을 구축하는것을 도와준다.
현재 EVM Jetson TX2의 JetPack을 설치를 진행했다면, 기본으로 설치가 되어있으며, 본인이 별도로 원한다면 별도 설치도 가능한 것 같다.


Nsight Eclipse Edition
  https://developer.nvidia.com/nsight-eclipse-edition

Nsight Eclipse Edition 관련 Manual
  https://docs.nvidia.com/cuda/nsight-eclipse-edition-getting-started-guide/index.html#introduction
  https://docs.nvidia.com/cuda/nsight-eclipse-plugins-guide/index.html


1.1 JetPack 3.3 기능확인  

JetPack은 3.3 과 4.1.1 이 존재하지만  JetPack 4.1.1 아직 설치를 해보지 못했으며, 현재 JetPack 3.3만 설치를 진행을 한 상태이다.
JetPack은 Nvidia사에서 제공해주는 Host Development Tool 과 각 Device의 SDK로 구성이 되어있으며, 각 기능을 구분해서 잘 알아두자.

NVIDIA에서 JetPack에서는 Jetson TX2 SDK를 다음과 같은 기능 제공해준다.
자세한 내용은 Download 사이트와 Manual 참조
  • OS : Ubuntu  (L4T28.2.1)
  • Libraries : TensorRT/cuDNN / VisionWorks/ OpenCV /MultiMedia API 
  • Developer Tools

CUDA Tools
  https://developer.nvidia.com/debugging-solutions

Nsight Systems
  https://developer.nvidia.com/nsight-systems

Nsight Graphics
  https://developer.nvidia.com/nsight-graphics

TensorRT
  https://docs.nvidia.com/deeplearning/sdk/tensorrt-sample-support-guide/index.html
 https://github.com/NVIDIA-AI-IOT/tf_to_trt_image_classification#convert

Deep Learning SDK
  https://docs.nvidia.com/deeplearning/sdk/index.html


  https://ngc.nvidia.com/catalog/landing

  • JetPack Download
JetPack의 기능 및 Version 그리고 해당 보드 관련사항 확인
  https://developer.nvidia.com/embedded/jetpack

  • JetPack Manual 
상위정보들이 자세히 설명되어있으니, 반드시 확인
  https://docs.nvidia.com/jetson/jetpack/index.html

  • JetPack Archive
각 개별 JetPack Version들을 알아보자
  https://developer.nvidia.com/embedded/jetpack-archive


1.2 CUDA Toolkit 

NVIDIA에서는 CUDA Toolkit을 배포하고 있으며, 이안에는 NVCC/CUDA-GDB 및 개발환경이 구성이 되어있다.
TI처럼 NVIDIA의 Compiler 및  관련 Binutil을 별도로 제공하고 있으며,  Cross GCC의 개념으로 이해하면 될 것 같다.

NVIDIA에서는 CUDA관련된 Version에 이름이 존재하는 것 같으며 각각 Maxwell, Pascal 이 존재하는 것 같다.

CUDA Toolkit Version 별 배포
  https://developer.nvidia.com/cuda-toolkit-archive

CUDA Toolkit 및 NVCC 관련정보
  https://docs.nvidia.com/cuda/index.html

CUDA NVCC(CUDA Compiler) GDB 관련정보
  https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
  https://docs.nvidia.com/cuda/cuda-gdb/index.html

1.3 NVIDIA 기타 개발툴 정보 

아직 사용해보지 못했으며, 추후 기회가 있다면 다시 검토를 해보자.

NVIDIA에서 제공하는 Developer Tools
  https://developer.nvidia.com/tools-overview

Nsight Visual Studio Edition
  https://developer.nvidia.com/nsight-visual-studio-edition

1.4 Jetson TX2의 Gstreamer 관련 정보 

추후 이부분은 python or command로 간단히 테스트를 진행을 해봐야 할 것 같으며, 간단히 간단히 테스트 한 후
관련기능을 따로 분리하여 기술한다.

Jetson Tx2 Gstreamer 관련정보
  https://developer.download.nvidia.com/embedded/L4T/r28_Release_v1.0/Docs/Jetson_TX2_Accelerated_GStreamer_User_Guide.pdf?fyfql6tLeytPjeEWlf9cmzFMS-kKyNcs3JrYDhp9oRT4q2MrtQc6r_NvoeMQIvlwddGG0FEeRTX3gIVF_qITlT_BmK9C5TZCxnc0dd3sKEZj0v8sykAGEozzCQB28U_3kajqqA4Sybn6tIz5v0CMBMkIHigbgTkBdh15DJf207mYxn35u8euwDWBM6SYyyE-Lw

2. Nsight Eclipse Edition 

JestsonTX2 개발환경에서 JetPack3.3 설치하여 자동으로 Ubuntu 16.04에  Nsight가 설치되었으며, 별도의 설치를 진행하지 않았다.

$ which nsight       // nsight 설치 위치 
/usr/local/cuda-9.0/bin/nsight

$ ls /usr/local/cuda-9.0/bin/
bin2c        cuda-gdb                     cuda-memcheck  cuobjdump            nsight                       nvcc.profile  nvprof   ptxas
computeprof  cuda-gdbserver               cudafe         fatbinary            nsight_ee_plugins_manage.sh  nvdisasm      nvprune
crt          cuda-install-samples-9.0.sh  cudafe++       gpu-library-advisor  nvcc                         nvlink        nvvp

$ nsight    // Nsight 실행 


별도의 설치를 한다면 상위 Nsight Eclipse Version 별도로 Download하여 설치를 추후 진행을 해보자.

Eclipse 기본사용법
  https://ahyuo.blogspot.com/search/label/IDE-Eclipse

Nsight Eclipse
  https://devblogs.nvidia.com/cuda-jetson-nvidia-nsight-eclipse-edition/


2.1 Nsight 의 TEST Program 작성 및 기본 TEST

현재 CUDA C/C++ Project는 문제가 없으므로, C/C++ 중심으로 테스트를 진행을 해본다.

File->New->C++ Project 실행













빌드 후 생성된 TEST ELF 파일을  sftp 이용하여 command 전송 후 테스트를 진행해 본다.


  • Host PC (Ubuntu 16.04) SFTP 전송 

$ cd ~/cuda-workspace/TEST/Debug/
$ ls 
TEST  makefile  objects.mk  sources.mk  src

$ readelf -a TEST | head    // ARM Version 인지 확인 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x1


//SFTP 이용하여 TEST File 전송 

$ sftp nvidia@10.0.0.170   // JestonTx2 유선 연결 
or
$ sftp nvidia@192.168.55.2 // JetsonTx2 USB Ethernet 연결 

sftp> ls
Desktop                         Documents                       Downloads                       Music                           
NVIDIA_CUDA-9.0_Samples         Pictures                        Public                          Templates                       
Videos                          VisionWorks-SFM-0.90-Samples    examples.desktop                jetson_clocks.sh                
jhlee                           tegra_multimedia_api            tegrastats                      weston.ini  

sftp> put TEST 
Uploading TEST to /home/nvidia/TEST
TEST                                                                                           100%   67KB  67.4KB/s   00:00  

sftp> exit


  • HOST PC USB-ACM0 접속 

Host에서 USB ACM0 or USB CDC-ECM 으로 접속하여 Target에서 실행

$ sudo minicom -s   //ttyACM0 접속 

nvidia@tegra-ubuntu:~$ ./TEST
!!!Hello World!!!



2.2 SSH와  CUDA-GDB 이용하여 Debug 기능 설정  

Project Explorer창에서  TEST Project에서 우측 마우스 버튼을 클릭
  1. Run As->Run Configurations 선택  
  2. Debug As->Debug Configurations 선택 

  • Run Configuration 창 


Remote Connection의 우측 Manage 선택


Remote Connection 설정

이미 JetsonTx2의 usb0의 주소 192.168.55.2 설정됨
nvidia / ubuntu  두개의 ID 중 선택




상위 Remote toolkit을 아래와 같이 설정
/usr/local/cuda/bin




  • Run Configuration 설정확인




  • Run Configuration 의 CUDA-GDB -> Legacy Remote 변경 
현재 CUDA-GDB를 이용하고 있으며, 이를 일반적으로 변경을 원한다면  Run Configuration의 하단의

Using CUDA-GDB Remote Debugging Launcher- Select other 선택 


  • Debug Configuration 의 CUDA-GDB -> Legacy Remote 변경 
좀 더 다양한 기능을 제공하지만 현재 CUDA-GDB Remote Debugging Launcher만 작동
(일반 GDB와 통신지원이 되지 않는다)


GDB Remote
  http://sourceware.org/gdb/onlinedocs/gdb/Connecting.html
  https://sourceware.org/gdb/onlinedocs/gdb/Server.html
  https://www.hahwul.com/2015/11/debugging-gdb-using-gdb-for-remote.html


2.3  Remote Debug 및 BreakPoint 기능제공

상위에서 기본적으로 CUDA-GDB Remote 시스템으로 설정을 하면 아래와 같이 원격 Debug Mode가 작동이 되며,
Break Point 및 다양한 기능을 사용할 수 있다.

  • Break point 설정 
JTAG에서 제공하는 프로그램 처럼 GDB를 이용하여 프로그램의 Breakpoint를 사용하여 제어가 가능하다.




  • Debug Mode 실행확인 
  1. Project Explorer창에서  TEST Project에서 우측 마우스 버튼을 클릭
  2. Debug As->Remote C/C++ Application 선택 




아래의 영상은 CUDA C/C++를 이용하여 TEST를 진행을 하고 있으며, 이를 참조하여 Cuda도 적용해보자.
    https://www.youtube.com/watch?v=2Mi3MRKtg2M

예전에 GDB를 이용한 DDD처럼 각 기능을 Eclipse에서 사용할 수 있어 편했으며, Nsight의 기본기능확인이니,
세부기능인 Profiler / Memory Access / Disasemble/ Graph 기능 지원여부를 알아보도록하자.

TI에서 지원되는 것처럼 다 지원이 될 것 같은데, 다만 JTAG 대신 GDB을 이용하여 하기 때문에 기능제한이 있을 거라고 생각한다.

3. Tegra System Profiler (NVIDIA System Profiler)


$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd  NVIDIA_System_Profiler
$ ls 
Host-x86_64  Target-arm  Target-arm-linux

$ cd Host-x86_64
$ ./SystemProfiler                // Tegra System Profiler  실행 

실행시 다음과 같이 실행

  • SSH를 이용하여 Jetson TX2 과 연결 



  • PID를 이용하여 Profile 진행 


상위에 지원되지 않는 Trace는 우측에 !로 표시되므로 관련부분은 미체크하고 실행


4.  NVIDIA Visual Profiler

Nsight Ecplise Edition에 포함되는 기능으로 개별적으로 실행이 가능하지만, 가급적 상위 Ecplise Edition으로 실행해서 사용하는 것이 좋다.


$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd devtools_docs
$ ls 
NVIDIA System Profiler 4.0  Tegra Graphics Debugger 2.5     // 관련 Manual 참조 

  • 실행방법 
$ sudo /usr/local/cuda-9.0/bin/nvvp 



동일하게 SSH로 연결이 되지만 어떻게 사용하는 것인지는 매뉴얼을 자세히 봐야겠다.


관련메뉴얼
  https://docs.nvidia.com/cuda/profiler-users-guide/index.html#visual


5.  Tegra-Graphics-Debugger


  • 관련 설명서 참고 

$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd devtools_docs
$ ls 
NVIDIA System Profiler 4.0  Tegra Graphics Debugger 2.5     // 관련 Manual 참조 

아직 필요성을 크게 느끼지 못해 사용하지 않고 있으며, 추후 자세한 기능을 알게된다면, 그때 다시 사용하도록 하자.


  • 실행방법 

$ sudo /usr/local/Tegra-Graphics-Debugger-2.5/nvidia-gfx-debugger 

//Error 
/usr/local/Tegra-Graphics-Debugger-2.5/nvidia-gfx-debugger.bin: error while loading shared libraries: libgstreamer-0.10.so.0: cannot open shared object file: No such file or directory

Ubuntu 16.04는 gstreamer 0.10을 현재 미지원
   https://github.com/toggl/toggldesktop/issues/1894

Gstreamer 0.10을 직접 Download
  https://devtalk.nvidia.com/default/topic/1026605/linux-graphics-debugger/error-loading-shared-libraries/

관련 메뉴얼
   https://developer.nvidia.com/tegra-graphics-debugger

댓글 없음 :