MATLAB Answers

Generate Cuda code from a pretrained rlDDPGAgent object for NVIDIA board

12 views (last 30 days)
I want to use a pretrained rlDDPGAgent for my NVIDIA Jetson Nano.
With this Agent i want to steer a model car, so the actor net ends with a hyperbolic tangent layer.
Is there a way to use for example the GPU Coder to do the transformation or another suggested possibility?
Due to my account at university i have access to all of the matlab content.


Sign in to comment.

Accepted Answer

Emmanouil Tzorakoleftherakis
If you see here, tha tanhLayer support code generation with GPU Coder starting in R2019b.


Show 2 older comments
Oliver Struck
Oliver Struck on 5 Mar 2020
The site of the doc helped a lot and i implemented the following code lines:
cfg = coder.gpuConfig('mex');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('cudnn');
%% Observationinfo
obsInfo = getObservationInfo(Car_Agent);
argstr = '{ones(obsInfo.Dimension(1),obsInfo.Dimension(2))}';
%% Code-Generation
For the compilation i selected the Visual C++ 2019 Compiler.
Then the process started and i received a build error with following failures:
  • build/win64/MWTanhLayerImpl.obj step [1/19]
  • build/win64/MWTanhLayer.obj step [2/19]
  • build/win64/cnn_api.obj step [3/19]
  • build/win64/MWCNNLayerImpl.obj step [5/19]
  • build/win64/predict.obj step [6/19]
  • build/win64/_coder_evaluatePolicy_api.obj step [7/19]
  • build/win64/MWTargetNetworkImpl.obj step [8/19]
  • build/win64/DeepLearningNetwork.obj step [9/19]
  • ninja: build stopped: subcommand failed step [10/19]
If it is necessary i can give you the complete build log.
Emmanouil Tzorakoleftherakis
This page has a list with prerequisites you need to have before generating GPU code. Specifically, you need the GPU Coder interface for Deep Learning libraries and the cudnn/tensorrt libraries installed. The env paths should be properly set up as well. Do you have these installed?
Oliver Struck
Oliver Struck on 6 Mar 2020
Finally i got it! All Matlab content was already installed, and the libraries were added to the CUDA Toolkit file, but i forgot to implement the environment variables and i forgot to add them to my Matlab workaround. After i did this the code generation was succesful. Thanks a lot for the good advices.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!