runExecutable - Launch an executable on the NVIDIA target by name - MATLAB (original) (raw)
Main Content
Launch an executable on the NVIDIA target by name
Syntax
Description
[procID](#mw%5Fbc273fe2-05ea-4695-a35a-a077f48b57cd) = runExecutable([hwObj](#mw%5F13dd3b12-f07f-430d-a8a3-2c961efcf287%5Fsep%5Fmw%5Fbcc65819-faa5-4997-9bca-35a8da7d894a),[exe](#mw%5Fd9c6763b-4b98-435e-b3b3-12e9cd4b7626))
launches the executable specified by exe
on the NVIDIA® target board desktop. exe
must include the complete path to the executable.
It is recommended to use the runApplication function to launch an executable on the target. With this function, the software can automatically determine the location of the executable on the NVIDIA target.
[procID](#mw%5Fbc273fe2-05ea-4695-a35a-a077f48b57cd) = runExecutable(___,[exeArgs](#mw%5F879dbc4f-f8fa-471d-b4b3-c3589266a880))
launches the executable specified by exe
on the NVIDIA target board desktop. exeArgs
is used to specify run-time arguments to the executable.
Examples
This example shows how to launch an executable on the NVIDIA Jetson™ TX2 target. This example requires a USB camera connected to the NVIDIA target.
Create a live hardware connection from the MATLAB® software to the NVIDIA hardware by using the jetson function. To create a live hardware connection object, provide the host name or IP address, user name, and password of the target board. For example:
hwobj = jetson('jetson-board-name','ubuntu','ubuntu');
Create a MATLAB function liveCapture.m
that connects to the webcam on a Jetson TX2 board and displays the image on the board. This function acts as the_entry-point_ for code generation.
function liveCapture() %#codegen
% To enable code generation for hardware interfaces hwobj = jetson; w = webcam(hwobj,1,'1280x800'); d = imageDisplay(hwobj);
for k = 1:2000 % Capture the image from the webcam on hardware. img = snapshot(w); % Display image. image(d,img); end
Create a GPU code configuration object for generating an executable. Use thecoder.hardware function to create a configuration object for the Jetson platform and assign it to the Hardware
property of the code configuration object cfg
.
cfg = coder.gpuConfig('exe'); cfg.GenerateReport = true; cfg.Hardware = coder.hardware('NVIDIA Jetson'); cfg.CustomInclude = fullfile('codegen','exe','liveCapture','examples'); cfg.CustomSource = fullfile('codegen','exe','liveCapture','examples','main.cu');
The main.cu
file is generated as part of code generation process. For this example, you can use this file without modification.
To generate CUDA® code, use the codegen command and pass the GPU code configuration object along with the liveCapture
entry-point function. After the code generation takes place on the host, the generated files are copied over and built on the target.
codegen -config cfg liveCapture
Use the runExecutable
function to launch the executable on the TX2 board.
exe = [hwobj.workspaceDir '/liveCapture.elf']; procID = runExecutable(hwobj,exe)
Launching the executable on the target...
Executable launched successfully with process ID 12821. Displaying the simple runtime log for the executable...
Input Arguments
Connection to a specific NVIDIA hardware board, specified as a jetson or drive object.
Specify the full path to the application that must be launched on the NVIDIA target desktop. You can use the workspaceDir
property of the jetson ordrive object to determine the standard location of the application.
Example: '/home/ubuntu/myLiveEdgeDetect/MATLAB_ws/R2019a/home/gpucoder/myLiveEdgeDetection/myLiveEdgeDetection.elf'
Specify the runtime arguments to the application.
Example: 'camVid.avi'
Output Arguments
The process ID of the application launched on the NVIDIA target.
Example: 12821
Version History
Introduced in R2019a
See Also
Functions
- jetson | drive | snapshot | imageDisplay | system | openShell | killApplication | killProcess | runApplication
Objects
Topics
- Sobel Edge Detection on NVIDIA Jetson Nano Using Raspberry Pi Camera Module V2
- Getting Started with the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms
- Deploy and Run Sobel Edge Detection with I/O on NVIDIA Jetson Nano
- Build and Run an Executable on NVIDIA Hardware
- Stop or Restart an Executable Running on NVIDIA Hardware
- Run Linux Commands on NVIDIA Hardware