Slim installation of MATLAB Runtime

144 次查看(过去 30 天)
Paul Wright
Paul Wright 2021-3-22
编辑: Stefanie Schwarz 2024-9-19,20:44
I want to create a Docker image with MATLAB Runtime and a compiled MATLAB executable. The executable only uses core MATLAB, so I do not want to install every available product because that will make the Docker image file unnecessarily large. I have tried using the installer_input.txt file to select only the MATLAB product (plus parallel computing toolbox in my case) but when I run my executable I get:
error while loading shared libraries: libmwlaunchermain.so: cannot open shared object file: No such file or directory
I am aware of the other answers fixing this error by setting LD_LIBRARY_PATH. In my case, this is correctly set, but the library file itself is missing, presumably because it is part of one of the products I omitted. I do not get this error when I install MATLAB Runtime with default settings that include every available product.
Which product contains libmwlaunchermain.so? Which are the minimum product(s) I need for MATLAB Runtime to work correctly (in case there are any other missing libraries)?

回答(3 个)

Paul Wright
Paul Wright 2021-3-24
After a bit of digging, I have partially answered my own question. There are two places where the products a standalone app requires are listed:
  1. The output of compiler.build.standaloneApplication
  2. In the standalone app's root directory in file requiredMCRProducts.txt.
For my application, I found (1) and (2) listed different products, and I needed to include all of them for the application to run. The file in (2) just lists product numbers. These are linked to product names files in the MATLAB Runtime installer's productData subdirectory. These are given in the table below, with a corresponding instruction line.
Once the required products are identified, MATLAB Runtime can be installed selectively using the -inputFile argument when running MATLAB Runtime install. The input file should include the instruction lines from the table and any other necessary arguments. For an example input file, please see my other question.
This method works in MATLAB R2021a. It does not work in R2019b. Perhaps a Mathworks staff member can confirm when the selective install function was added. I suspect it came along with the ability to package standalone applications into Docker images in R2020b. https://uk.mathworks.com/help/compiler/release-notes.html
Table linking product numbers to input file instruction lines. Used commented code because I couldn't figure out how to insert a table.
%productNumber productName instruction
%35000 MATLAB Runtime - Core product.MATLAB_Runtime___Core true
%35010 MATLAB Runtime - Numerics product.MATLAB_Runtime___Numerics true
%35051 MATLAB Runtime - NET And Excel Addin product.MATLAB_Runtime___NET_And_Excel_Addin true
%35052 MATLAB Runtime - Hadoop And Spark Addin product.MATLAB_Runtime___Hadoop_And_Spark_Addin true
%35053 MATLAB Runtime - Java Addin product.MATLAB_Runtime___Java_Addin true
%35054 MATLAB Runtime - Production Server Addin product.MATLAB_Runtime___Production_Server_Addin true
%35055 MATLAB Runtime - Python product.MATLAB_Runtime___Python true
%35103 MATLAB Runtime - Control System Toolbox Addin product.MATLAB_Runtime___Control_System_Toolbox_Addin true
%35104 MATLAB Runtime - System Identification Toolbox Addin product.MATLAB_Runtime___System_Identification_Toolbox_Addin true
%35106 MATLAB Runtime - Optimization Toolbox Addin product.MATLAB_Runtime___Optimization_Toolbox_Addin true
%35108 MATLAB Runtime - Signal Processing Toolbox Addin product.MATLAB_Runtime___Signal_Processing_Toolbox_Addin true
%35111 MATLAB Runtime - Mapping Toolbox Addin product.MATLAB_Runtime___Mapping_Toolbox_Addin true
%35112 MATLAB Runtime - Deep Learning Toolbox Addin product.MATLAB_Runtime___Deep_Learning_Toolbox_Addin true
%35117 MATLAB Runtime - Image Processing Toolbox Addin product.MATLAB_Runtime___Image_Processing_Toolbox_Addin true
%35119 MATLAB Runtime - Statistics and Machine Learning Toolbox Addin product.MATLAB_Runtime___Statistics_and_Machine_Learning_Toolbox_Addin true
%35122 MATLAB Runtime - Model Predictive Control Toolbox Addin product.MATLAB_Runtime___Model_Predictive_Control_Toolbox_Addin true
%35123 MATLAB Runtime - Fuzzy Logic Toolbox Addin product.MATLAB_Runtime___Fuzzy_Logic_Toolbox_Addin true
%35124 MATLAB Runtime - DSP System Toolbox Addin product.MATLAB_Runtime___DSP_System_Toolbox_Addin true
%35130 MATLAB Runtime - Financial Toolbox Addin product.MATLAB_Runtime___Financial_Toolbox_Addin true
%35131 MATLAB Runtime - Partial Differential Equation Toolbox Addin product.MATLAB_Runtime___Partial_Differential_Equation_Toolbox_Addin true
%35135 MATLAB Runtime - Wavelet Toolbox Addin product.MATLAB_Runtime___Wavelet_Toolbox_Addin true
%35136 MATLAB Runtime - Communications Toolbox Addin product.MATLAB_Runtime___Communications_Toolbox_Addin true
%35141 MATLAB Runtime - Database Toolbox Addin product.MATLAB_Runtime___Database_Toolbox_Addin true
%35144 MATLAB Runtime - MATLAB Report Generator Addin product.MATLAB_Runtime___MATLAB_Report_Generator_Addin true
%35150 MATLAB Runtime - Datafeed Toolbox Addin product.MATLAB_Runtime___Datafeed_Toolbox_Addin true
%35160 MATLAB Runtime - Curve Fitting Toolbox Addin product.MATLAB_Runtime___Curve_Fitting_Toolbox_Addin true
%35162 MATLAB Runtime - Instrument Control Toolbox Addin product.MATLAB_Runtime___Instrument_Control_Toolbox_Addin true
%35166 MATLAB Runtime - Simulink 3D Animation Addin product.MATLAB_Runtime___Simulink_3D_Animation_Addin true
%35178 MATLAB Runtime - Image Acquisition Toolbox Addin product.MATLAB_Runtime___Image_Acquisition_Toolbox_Addin true
%35180 MATLAB Runtime - Parallel Computing Toolbox Cluster Addin product.MATLAB_Runtime___Parallel_Computing_Toolbox_Cluster_Addin true
%35183 MATLAB Runtime - Bioinformatics Toolbox Addin product.MATLAB_Runtime___Bioinformatics_Toolbox_Addin true
%35186 MATLAB Runtime - RF Toolbox Addin product.MATLAB_Runtime___RF_Toolbox_Addin true
%35190 MATLAB Runtime - Global Optimization Toolbox Addin product.MATLAB_Runtime___Global_Optimization_Toolbox_Addin true
%35191 MATLAB Runtime - Fixed-Point Designer Addin product.MATLAB_Runtime___Fixed_Point_Designer_Addin true
%35196 MATLAB Runtime - Computer Vision Toolbox Addin product.MATLAB_Runtime___Computer_Vision_Toolbox_Addin true
%35203 MATLAB Runtime - SimBiology Addin product.MATLAB_Runtime___SimBiology_Addin true
%35208 MATLAB Runtime - Aerospace Toolbox Addin product.MATLAB_Runtime___Aerospace_Toolbox_Addin true
%35212 MATLAB Runtime - Phased Array System Toolbox Addin product.MATLAB_Runtime___Phased_Array_System_Toolbox_Addin true
%35224 MATLAB Runtime - Vehicle Network Toolbox Addin product.MATLAB_Runtime___Vehicle_Network_Toolbox_Addin true
%35225 MATLAB Runtime - Econometrics Toolbox Addin product.MATLAB_Runtime___Econometrics_Toolbox_Addin true
%35227 MATLAB Runtime - Simulink Design Optimization Addin product.MATLAB_Runtime___Simulink_Design_Optimization_Addin true
%35236 MATLAB Runtime - Financial Instruments Toolbox Addin product.MATLAB_Runtime___Financial_Instruments_Toolbox_Addin true
%35240 MATLAB Runtime - LTE Toolbox Addin product.MATLAB_Runtime___LTE_Toolbox_Addin true
%35242 MATLAB Runtime - Robotics System Toolbox Addin product.MATLAB_Runtime___Robotics_System_Toolbox_Addin true
%35245 MATLAB Runtime - WLAN Toolbox Addin product.MATLAB_Runtime___WLAN_Toolbox_Addin true
%35250 MATLAB Runtime - Risk Management Toolbox Addin product.MATLAB_Runtime___Risk_Management_Toolbox_Addin true
%35251 MATLAB Runtime - Audio Toolbox Addin product.MATLAB_Runtime___Audio_Toolbox_Addin true
%35252 MATLAB Runtime - Automated Driving Toolbox Addin product.MATLAB_Runtime___Automated_Driving_Toolbox_Addin true
%35256 MATLAB Runtime - Text Analytics Toolbox Addin product.MATLAB_Runtime___Text_Analytics_Toolbox_Addin true
%35257 MATLAB Runtime - Sensor Fusion and Tracking Toolbox Addin product.MATLAB_Runtime___Sensor_Fusion_and_Tracking_Toolbox_Addin true
%35258 MATLAB Runtime - Predictive Maintenance Toolbox Addin product.MATLAB_Runtime___Predictive_Maintenance_Toolbox_Addin true
%35261 MATLAB Runtime - 5G Toolbox Addin product.MATLAB_Runtime___5G_Toolbox_Addin true
%35272 MATLAB Runtime - Reinforcement Learning Toolbox Addin product.MATLAB_Runtime___Reinforcement_Learning_Toolbox_Addin true
%35274 MATLAB Runtime - Rapid Accelerator product.MATLAB_Runtime___Rapid_Accelerator true
%35275 MATLAB Runtime - ROS Toolbox Addin product.MATLAB_Runtime___ROS_Toolbox_Addin true
%35276 MATLAB Runtime - Navigation Toolbox Addin product.MATLAB_Runtime___Navigation_Toolbox_Addin true
%35278 MATLAB Runtime - Lidar Toolbox Addin product.MATLAB_Runtime___Lidar_Toolbox_Addin true
%35281 MATLAB Runtime - Radar Toolbox Addin product.MATLAB_Runtime___Radar_Toolbox_Addin true
%35282 MATLAB Runtime - UAV Toolbox Addin product.MATLAB_Runtime___UAV_Toolbox_Addin true
%35380 MATLAB Runtime - Parallel Computing Toolbox GPU Addin product.MATLAB_Runtime___Parallel_Computing_Toolbox_GPU_Addin true
%35500 MATLAB Runtime - Web Apps Addin product.MATLAB_Runtime___Web_Apps_Addin true
  3 个评论
Benjamin Tomlinson
Benjamin Tomlinson 2022-12-20
Thanks for your research Paul - I think it's ridiculous that Matlab don't officially document this functionality as I think many people would find it useful. My Docker image has now been reduced from 10 GB to 2 GB - much more manageable.
Just FYI, I created a python script which takes as inputs (1) the complete MCR and (2) "requiredMCRProducts.txt" and outputs the input file as described in your other question. Within the complete MCR folder "productdata", there is a list of files with productNumber (e.g. 35000) which contain the productName (e.g. Core) which can be used to build the instruction for the input file (e.g product.MATLAB_Runtime___Core true).
Thanks again for your posts/answers
Wolf Blecher
Wolf Blecher 2023-3-8
Digging deep into the Matlab internals, I found the following piece of code, giving me the information directly from the Command line, so this could be used in a Matlab-Script:
pcmn = matlab.depfun.internal.ProductComponentModuleNavigator;
pcmn.productInfo(35000) % Insert your number here

请先登录,再进行评论。


Raymond Norris
Raymond Norris 2021-3-22
  3 个评论
Raymond Norris
Raymond Norris 2021-3-22
I would expect that the generated docker image will include all MATLAB libraries needed based on the products you need for the code you're running for the MATLAB Runtime.
If you build it on your own, also look at https://github.com/mathworks-ref-arch/container-images (note these are for Ubuntu but ought to get you heading in the right direction) for 3p library dependencies MATLAB has.
Paul Wright
Paul Wright 2021-3-22
It looks like my problem is in fact that nothing at all is being installed, so my problem is likely with the installer_input.txt file. I ask about that in a separate question.
For the community, it would still be good to know how to perform selective installation of products in Runtime, whether using an input file or inline options. The method you gave, using compiler.package.docker does this, apparently using requiredMCRProducts.txt from the compiled function. That method is automated, and people (me included) may want to make their own Dockerfile. In this case, it's not clear how to replicate the part of the automated process that selectively installs the products.

请先登录,再进行评论。


Stefanie Schwarz
Stefanie Schwarz 2024-9-19,20:39
编辑:Stefanie Schwarz 2024-9-19,20:44
For newer versions of MATLAB, there are supported ways to create selective MATLAB Runtime installers and Docker containers with 'compiler.runtime.customInstaller' and 'compiler.runtime.createDockerImage'.
For more information, see:

类别

Help CenterFile Exchange 中查找有关 Containers 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by