Nsight Eclipse IDE: Set up the NVIDIA Nsight Eclipse IDE for efficient development on your host and target

Intro:

The NVIDIA DRIVE™ AGX Developer System enables you to accelerate development with our DRIVE software stack.

The NVIDIA DriveWorks Software Development Kit (SDK) includes a number of open-source reference samples, development tools, and library modules targeting autonomous driving applications.

After properly configuring your development environment, you can customize these samples or develop your own applications on your Linux host machine, executing them either on the host or on the DRIVE platform.

We will show here how to configure the NVIDIA Nsight Eclipse Edition to enable host and target compilation process and execution for our samples. Nsight Eclipse provides a full-featured Integrated Development Environment (IDE) powered by Eclipse. The all-in-one integrated environment allows you to edit, build, and debug CUDA C/C++ applications. We will show how to import, compile, run, and debug a DriveWorks project on both a host machine and Drive platform remotely. This takes place directly from within the Nsight IDE, exploiting the original sample makefiles.

Preconditions:

  • Before diving into the configuration, make sure you are logged in on your host machine and connected to the target.

  • Please refer to the SDK Manager installation guide found on the DRIVE Program Download page in order to install all the necessary components.

  • Make sure that the requested sample (for example LaneNet sample) runs correctly before proceeding. Do this by executing the following code in a terminal window both on your host and on your NVIDIA DRIVE device.
    cd /usr/local/driveworks/bin
    ./sample_lane_detection

Preparing the framework:

Note: your CUDA version may vary from the illustrations and mentions throughout this document.

  1. On your host system, create a directory and copy the included content that comes with the installation into it.
    mkdir ~/samples-nsight
    cd /usr/local/driveworks
    cp –r /usr/local/driveworks/samples ~/samples-nsight/
    cp –r /usr/local/driveworks/data ~/samples-nsight

  2. For Nsight Eclipse you need to export your CUDA binaries for development.
    export PATH=$PATH:/usr/local/cuda-<version>/bin
    Then run the Nsight Eclipse IDE by executing the following:
    nsight

Technical note: Currently Nsight Eclipse does not support HiDpi and thus the icons in the toolbar may be very tiny. This can be easily resolved by scaling the resolution down to full HD.

  1. Now we want to install the cmake4eclipse plugin in the next step.

Technical note: Optionally, you can install the CMake Editor plugin as well for syntax highlighting by entering jar:https://dl.bintray.com/15knots/p2-zip/CMakeEd-1.8.0.zip!/ in the “Work with” text box.

  1. Once installed the plugin, create a new CUDA C/C++ project:
  • Select “File > New > Project > C/C++ > CUDA C/C++ Project”
  • Enter a project name
  • Uncheck “Use default location” and browse to “~/samples-nsight/samples”
  • Select “Empty Project” under “Project type”
  • Select “CUDA Toolkit X.Y” under “Toolchains”
  • Click “Finish” and create the project
  1. Optional: In your Nsight window, now edit the CMakeLists.txt file to leave to compilation only the relevant samples:
  • Select “[Project Name] > samples > CMakeLists.txt”
  • Open the file e.g. via double-click
  • replace set(SAMPLES framework;...) with the samples you want to build, for example, if we want to build laneDetection sample we replace the line with: set(SAMPLES framework;dnn;laneDetection)
  • Save the file

Compile and execute for the host:

Now let’s work through the steps for setting up the host environment configuration by creating a build configuration and selecting the proper toolchain, so that the cmake4eclipse plugin will be used whenever you build the project within Nsight.

  1. from the Project Explorer window Right-click on the project name and select “Properties”.

  2. Go to the “Build -> Cmake4eclipse” tab and click on “Manage Configurations…”.

  3. Select “New” to create a configuration: use build-host as “Name”, select “Debug: CUDA Toolkit X.Y” as “Default configuration”.

  4. Click “OK” and “Set Active” and then “OK” again.

  5. Under “Configuration:” now select it

  6. As “Folder” enter ${ConfigName} only

  7. Switch to the Symbols tab

  8. Click on the “Add…” button, and type CMAKE_BUILD_TYPE as “Variable name”, STRING as “Type” and Debug or ‘Release’ as “Value”

  9. Click “OK” and then again “Apply” to confirm.

  1. To specify the toolchain, open up the project’s “Properties” again and this time enter the “Tool Chain Editor”.
  • Select the “Tool Chain Editor”
  • Under “Current Builder” select “Cmake Builder (GNU Make)”, so that the cmake4eclipse plugin will be used)
  • Click “Apply” to confirm
  1. In the same “Properties” window, we need to configure some general C/C++ preprocessor properties.
  • Go to “C/C++ General -> Preprocessor Include Paths, Macros etc.”
  • Select “Providers” tab
  • Select the “CMAKE_EXPORT_COMPILE_COMMANDS Parser” line and move it up to the very top.
  • Click “Apply” and “OK” to confirm.

Technical note: Now the preprocessor includes paths will be derived automatically from the CMake configuration files.

  1. Now you can compile and execute your source code on your host.

Debugging for the host:

Let’s have a look at how to debug your code. The following steps show how to debug the sample ‘LaneNet’.

  1. Build the project by selecting “Project -> Build Project”
  2. Go to “Run -> Debug Configurations…”
  3. Select "C/C++ Application "
  4. Press “New”, name the configuration “LaneNet build-host”
  5. Select “Search Project” to select the debug executable of “sample_lane_detection”
  6. Switch to the “Arguments” tab
  7. Insert the following line for the sample to load the video file:
    --video=/usr/local/driveworks/data/samples/laneDetection/video_lane.h264
  8. Finally: Click “Debug”

You are now ready to run and debug your code with NVIDIA Nsight Eclipse.

Cross Compile for the Drive platform:

Now let’s work through the steps for setting up the host environment configuration by creating a build configuration and selecting the proper toolchain, so that the cmake4eclipse plugin will be used whenever you build the project within Nsight eclipse for the target.

  1. from the Project Explorer window Right-click on the project name and select “Properties”.

  2. Go to the “Build -> Cmake4eclipse” tab and click on “Manage Configurations…”.

  3. Select “New” to create a configuration: use build-target as “Name”, select “Debug: CUDA Toolkit X.Y” as “Default configuration”.

  4. Click “OK” and “Set Active” and then “OK” again.

  5. Under “Configuration:” now select it

  6. As “Folder” enter ${ConfigName} only

  7. Switch to the “Symbols” tab:

  • Click on the “Add…” button, and type CMAKE_BUILD_TYPE as “Variable name”, STRING as “Type” and Debug or ‘Release’ as “Value”
    and Click “OK”
  • Click on the “Add…” button, and type CMAKE_TOOLCHAIN_FILE as “Variable name”, STRING as “Type” and </path/to/driveworks/samples/cmake/Toolchain-V5L.cmake> as “Value” (for example /usr/local/driveworks/samples/cmake/Toolchain-V5L.cmake)
    and click “OK”
  • Click on the “Add…” button, and type VIBRANTE_PDK as “Variable name”, STRING as “Type” and </path/to/drive-t186ref-linux> as “Value” (for example ${HOME}/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux)
    and click “OK”
  • Click “Apply” to confirm.

  1. To specify the toolchain, open up the project’s “Properties” again and enter the “Tool Chain Editor”.
  • Select the “Tool Chain Editor”
  • Under “Current Builder” select “Cmake Builder (GNU Make)”, so that the cmake4eclipse plugin will be used)
  • Click “Apply” to confirm
  1. Finally, in the same “Properties” window, we need to configure some general C/C++ preprocessor properties.
  • Go to “C/C++ General -> Preprocessor Include Paths, Macros etc.”
  • Select the “Providers” tab
  • Select the “CMAKE_EXPORT_COMPILE_COMMANDS Parser” line and move it up to the very top.
  • Click “Apply” and “OK” to confirm.

Technical note: The preprocessor includes paths that will now be derived automatically from the CMake configuration files.

  1. Now you can compile your source code to be executed on the target.

Target remote execution and debug from the host:

Let’s have a look at how to debug your code. The following steps show how to debug the sample ‘LaneNet’.

  1. Build the project by selecting “Project -> Build Project”
  2. Go to “Run -> Debug Configurations…”
  3. Select "C/C++ Remote Application "
  4. Press “New”, name the configuration “LaneNet build-target”
  5. On “Remote Connections:” Press “Manage…”
  6. On the “new remote connection” window press “Add”
  7. Type the IP of the Target at the “Host name:” field
  8. Type the user name at the “User name:” field and press “Finish”
  9. On the “Remote toolkit:” Press “Manage…”
  10. On the “Cuda toolkits” window, Press “Detect…”
  11. A password request window will be prompted, enter the password for the target ssh connection
  12. If the “Connect” button appears Press “Connect” then Press “OK” and “Finish”.
  13. On “Remote executable:”, enter a location on the target that the compiled application will be copied in order to be executed. and press “Apply”.
  14. Switch to “Local” tab and Select “Search Project” to select the debug executable and press “Apply”.
  15. Switch to the “Arguments” tab to add arguments
  16. Insert the following line for the sample_lane_detection sample to load the video file:
    --video=/usr/local/driveworks/data/samples/laneDetection/video_lane.h264
  17. Switch to the “Environment” tab to set the DISPLAY environment variable for graphical applications (like DriveWorks)
  18. Press “New…” and type DISPLAY as “name”, :0 as “Value” and press “OK”
  19. Finally: Click “Apply”
    You are now ready to run and debug your code with NVIDIA Nsight Eclipse.
  20. for Remote Execution:
  • close Debug Configurations window and Go to “Run -> Run Configuration…”
  • select the configuration created above (“LaneNet build-target”) and press “Run”
  1. For Remote Debugging:
  • the “Remote connection” on section 5 (through ssh) must be defined with user root to have root priveledges.
  • when a remote connection is set with user root, select the configuration created above (“LaneNet build-target”) on the “Debug Configurations” window and press “Debug”.

General Technical Note 1: most of the DW samples use the graphical display, therefore the environment variable DISPLAY must be set before the execution of a sample
(On the Drive platform it is usually defined to :0 as only one display is connected,
hence the following command needs to be executed when connecting through ssh: export DISPLAY=:0).

General Technical Note 2: to allow ssh connection with root as a user name, the following actions need to be executed:
[a] edit file /etc/ssh/sshd_config (with root privileges)
change line:
#PermitRootLogin prohibit-password
to
PermitRootLogin yes
[b] restart sshd service:
sudo service sshd restart
[c] add password to root:
sudo passwd

General Technical Note 3: to allow the root user to execute a graphical application using the display the following command can be executed as a non-root user:
export DISPLAY=:0 && xhost local:root