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.
-
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
-
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.
- Now we want to install the
cmake4eclipse
plugin in the next step.
- Select “Help → Install New Software…”
- Enter the following text: jar:https://dl.bintray.com/15knots/p2-zip/cmake4eclipse-1.12.1.zip!/ in the “Work with” text box
- select CMake checkbox
- Click “Next >” and install the package
Thecmake4eclipse
plugin will help you to configure the CMake building process. The plugin also derives the includes automatically from the DriveWorks CMake configuration file.
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.
- 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
- 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.
-
from the Project Explorer window Right-click on the project name and select “Properties”.
-
Go to the “Build → Cmake4eclipse” tab and click on “Manage Configurations…”.
-
Select “New” to create a configuration: use build-host as “Name”, select “Debug: CUDA Toolkit X.Y” as “Default configuration”.
-
Click “OK” and “Set Active” and then “OK” again.
-
Under “Configuration:” now select it
-
As “Folder” enter
${ConfigName}
only
-
Switch to the
Symbols
tab -
Click on the “Add…” button, and type
CMAKE_BUILD_TYPE
as “Variable name”,STRING
as “Type” andDebug
or ‘Release’ as “Value” -
Click “OK” and then again “Apply” to confirm.
- 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
- 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.
- 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’.
- Build the project by selecting “Project → Build Project”
- Go to “Run → Debug Configurations…”
- Select "C/C++ Application "
- Press “New”, name the configuration “LaneNet build-host”
- Select “Search Project” to select the debug executable of “sample_lane_detection”
- Switch to the “Arguments” tab
- Insert the following line for the sample to load the video file:
--video=/usr/local/driveworks/data/samples/laneDetection/video_lane.h264
- 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.
-
from the Project Explorer window Right-click on the project name and select “Properties”.
-
Go to the “Build → Cmake4eclipse” tab and click on “Manage Configurations…”.
-
Select “New” to create a configuration: use build-target as “Name”, select “Debug: CUDA Toolkit X.Y” as “Default configuration”.
-
Click “OK” and “Set Active” and then “OK” again.
-
Under “Configuration:” now select it
-
As “Folder” enter
${ConfigName}
only
-
Switch to the “Symbols” tab:
- Click on the “Add…” button, and type
CMAKE_BUILD_TYPE
as “Variable name”,STRING
as “Type” andDebug
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.
- 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
- 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.
- 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’.
- Build the project by selecting “Project → Build Project”
- Go to “Run → Debug Configurations…”
- Select "C/C++ Remote Application "
- Press “New”, name the configuration “LaneNet build-target”
- On “Remote Connections:” Press “Manage…”
- On the “new remote connection” window press “Add”
- Type the IP of the Target at the “Host name:” field
- Type the user name at the “User name:” field and press “Finish”
- On the “Remote toolkit:” Press “Manage…”
- On the “Cuda toolkits” window, Press “Detect…”
- A password request window will be prompted, enter the password for the target ssh connection
- If the “Connect” button appears Press “Connect” then Press “OK” and “Finish”.
- On “Remote executable:”, enter a location on the target that the compiled application will be copied in order to be executed. and press “Apply”.
- Switch to “Local” tab and Select “Search Project” to select the debug executable and press “Apply”.
- Switch to the “Arguments” tab to add arguments
- 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
- Switch to the “Environment” tab to set the
DISPLAY
environment variable for graphical applications (like DriveWorks) - Press “New…” and type
DISPLAY
as “name”,:0
as “Value” and press “OK”
- Finally: Click “Apply”
You are now ready to run and debug your code with NVIDIA Nsight Eclipse. - for Remote Execution:
- close Debug Configurations window and Go to “Run → Run Configuration…”
- select the configuration created above (“LaneNet build-target”) and press “Run”
- 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