Generate Cuda code from a pretrained rlDDPGAgent object for NVIDIA board

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.
Greetings
Oliver

 採用された回答

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2020 年 3 月 4 日

0 投票

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

5 件のコメント

Oliver Struck
Oliver Struck 2020 年 3 月 4 日
Sure the layer is supported, but the GPU Coder can only support series and directed acyclic graph (DAG) or convolutional neural networks (CNNs or ConvNets). In my case i have a rlDDPGAgent object wich is none of them i think, correct me if i am wrong. I tried to rebuild the actor net as an DAG with all given information in the rlDDPG object and it worked but when i created a function of the actor net, the GPU Coder told me that he needs an output layer. The tanhLayer is not defined as a layer of this type.
Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2020 年 3 月 4 日
You shouldn't need to recreate the network yourself. If you look at the doc here, there is an automated process that takes the agent object and creates a function that does inference that should be compatible with GPU coder (the link has an example as well). Can you try this and let me know what errors you are seeing?
Oliver Struck
Oliver Struck 2020 年 3 月 5 日
The site of the doc helped a lot and i implemented the following code lines:
generatePolicyFunction(Car_Agent);
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
codegen('-config','cfg','evaluatePolicy','-args',argstr,'-report');
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
Emmanouil Tzorakoleftherakis 2020 年 3 月 5 日
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 2020 年 3 月 6 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with GPU Coder についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by