在 Ubuntu 20.04 上静默安装matlab 实践

这篇具有很好参考价值的文章主要介绍了在 Ubuntu 20.04 上静默安装matlab 实践。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

需求:

  1. 某服务端业务需要调用 matlab
  2. 为方便迭代发布,需要支持基于 docker 的自动化部署(CD)

方案对比

使用 Matlab 官方 docker 镜像

  • 一键安装,使用方便
  • 官方镜像仅支持网络验证
  • 官方镜像仅支持基础功能版、深度学习版两个版本,功能不全

使用 matlab runtime

  • 需要将编写好的 matlab 程序打包成对应框架(如:python、c++ 等)SDK。存在兼容性问题,同时操作较为复杂

使用 matlab server

  • 没有用过
  • 看文档,貌似用起来成本较大

定制 docker 镜像

使用 ubuntu:20.04 作为基础镜像,在容器中安装 matlab

  • 操作简单。需求方仅需要把 matlab 代码交付给开发人员,就可以使用
  • 灵活性强。可以根据具体业务安装对应模块
  • 兼容性好。理论上,服务端的执行效果和开发时的运行效果一致

使用规范

matlab 代码使用 pcode 工具混淆后部署到服务端


构建镜像

基础镜像

目的:加快实验速度,同时作为后续部署的基础镜像

FROM ubuntu:20.04
COPY . /root
RUN rm -f /etc/apt/sources.list && cp /root/sources.list /etc/apt/sources.list && rm -rf /var/lib/apt/lists/* && apt update && \
apt-get install -y python3 && apt-get install -y python3-pip && \
pip config --global set global.index-url http://mirrors.piprepohost.com/repository/pypi/simple/ && pip config --global set install.trusted-host mirrors.piprepohost.com && \
apt-get install -y libx11-6 && apt-get install -y libxt6 && apt-get install -y libglib2.0-0 && \
apt-get clean && apt-get -y autoremove && rm -rf /var/lib/apt/lists/*

Install

方法一:把容器保存成镜像

这里是把 matlab ISO 安装包映射到 docker 容器中。然后把容器打包成镜像。

// install
// txt 内容详见文章末尾
./install -inputFile inputFile.txt

// run
// 如果没有安装 jre 或其他 java 开发环境,需要携带 -nojvm 参数
/matlabroot/bin/matlab -nodisplay -nojvm

// install python engine allowing call matlab from python
cd /matlabroot/bin/extern//engines/python
python3 setup.py install
# 把容器保存为镜像
docker commit <containerid> <tag>

# 接下来可以通过以下两种方式分发镜像

# 上传到 harbor
docker push <tag>

# 保存成文件
docker save -o <filename>.tar <src-image-tag>
# 通过下面的命令导入镜像
# 导入后,新导入的镜像是没有 tag 的,记得打上 tag
docker load --input <filename>.tar

方法二:通过 Dockerfile 构建镜像

使用这种方法时,不能把 matlab 安装包放到 context 中,因为安装文件太大,会导致发送给 daemon 的时候崩溃或者卡死。

建议使用多阶段构建,在第一个阶段完成安装,第二个阶段保留安装完的数据。

构建时推荐使用 ADD 指令,从远端下载安装文件,然后执行安装 matlab 相关命令。


问题集合

no more space

  • matlab.internal.engine.input
    outputFile
  • no more space
// 查看磁盘占用情况,大概率是 docker 使用的磁盘空间满了
du -h
df -h

// 可以在 /etc/docker/daemon.json 中添加/修改 data-root 字段,选择空间最大的磁盘
// 改完后注意同步数据(把之前磁盘空间的内容拷贝到新磁盘空间,否则之前所有的 docker 内容都看不到)
"data-root"

// 重启 docker
systemctl daemonreload
systemctl restart docker

not found

  1. matlab 编码问题
  2. 加密系统自动加密问题
  3. pcode 混淆

在 dockerfile 使用 apt

当在 dockerfile 使用 apt 的时候,如果出问题,可以考虑设置如下环境变量。该环境变量有很多值,请自行 baidu

DEBIAN_FRONTEND=noninteractive

图形化安装

如果要图形化安装(使用 matlab 的安装 GUI 引导)。最好是注销当前账户,然后使用 root 登录系统。

如果是使用如下方式安装,会出现 GUI 看不到的情况

sudo su
./install

怀疑是此时的 X11 转发不能和当前账户共用导致。


installer_input.txt

这是 demo 样例,大家注意根据自己情况修改文件中的参数。文章来源地址https://www.toymoban.com/news/detail-531047.html

##################################################################
##
## Use this file to specify parameters required by the installer at runtime.
##
## Instructions for using this file.
##
## 1. Create a copy of this template file and fill in the required
##    information.
##
## 2. Uncomment only those lines that start with a single '#'
##    and set the desired values. All allowed values for the
##    parameters are defined in the comments section for each
##    parameter.
##
## 3. Launch the installer from the command line, using the -inputFile option
##    to specify the name of your installer initialization file.
##
##    (Windows) setup.exe -inputFile <file_name>
##    (Linux/macOS) install -inputFile <file_name>
##
##################################################################
##
##
## SPECIFY INSTALLATION FOLDER
## 
## Example:
##        (Windows) destinationFolder=C:\Program Files\MATLAB\RXXXX
##        (Linux) destinationFolder=/usr/local/RXXXX
##        (macOS) destinationFolder=/Applications
##
## Set the desired value for destinationFolder and
## uncomment the line.

destinationFolder=/home/jori/matlab

##
## SPECIFY FILE INSTALLATION KEY
##
## Example: fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx.....
##
## Set the desired value for fileInstallationKey and
## uncomment the line.
##

fileInstallationKey=09806-07443-53955-64350-21751-41297

##
## ACCEPT LICENSE AGREEMENT
##
## You must agree to the license agreement to install MathWorks products.
## The license agreement can be found in the license_agreement.txt file at the
## root level of the installation DVD.
##
## Example: agreeToLicense=yes
##
## Set agreeToLicense value to yes or no and
## uncomment the line.

agreeToLicense=yes

##
## SPECIFY OUTPUT LOG
##
## Specify full path of file into which you want the results of the
## installation to be recorded.
##
## Example:
##            (Windows) outputFile=C:\TEMP\mathworks_<user_name>.log
##            (Linux/macOS) outputFile=/tmp/mathworks_<user_name>.log
##
## Set the desired value for outputFile and
## uncomment the line.

outputFile=/tmp/mathworks_jori.log

##
## Enable Login Named User licensing
##
## Set to Yes to enable use of a Login Named User license for all users of this MATLAB installation
## Users must log in to their MathWorks Account when MATLAB starts.
##
## Example: enableLNU=yes
##
## NOTE: This flag is valid in silent installations only.

enableLNU=no

##
## IMPROVE MATLAB
##
## Improve MATLAB by sending user experience information to MathWorks.
## Your participation ensures that you are represented and helps us design
## better products. You can opt in or out of this service either during
## installation or by going to MATLAB preferences.
## https://www.mathworks.com/support/faq/user_experience_information_faq.html

improveMATLAB=no

########## Begin: Options for Network License Types #########
##
## SPECIFY PATH TO LICENSE FILE (Required for network license types only)
##
## This value is required when installing as a Network End-User
## Example:
##            (Windows) licensePath=C:\TEMP\license.dat
##            (Linux) licensePath=/tmp/license.dat
## Set the desired value for licensePath and
## uncomment the line.

isSilent=true
activateCommand=activateOffline
licensePath=/home/jori/2021acrack/license.lic
licenseFile=/home/jori/2021acrack/license.lic

########## End: Options for Network License Types #########


################# Begin - Windows Only Options ################
## 
## CHOOSE TO SET FILE ASSOCIATIONS
## 
## Set to true if you want the installer to associate file types used by MathWorks
## products to this version of MATLAB, or false if you do not want the installer to
## associate MathWorks file types with this version of MATLAB.
##
## Default value is true.
##
## Set setFileAssoc value to true or false and
## uncomment the line.

setFileAssoc=false

##
## CHOOSE TO CREATE WINDOWS DESKTOP SHORTCUT
##
## Set to true if you would like the installer to create a desktop shortcut icon
## when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is false.
##
## Set desktopShortcut value to true or false and
## uncomment the line.

desktopShortcut=false

## CHOOSE TO ADD SHORTCUT TO WINDOWS START MENU
##
## Set to true if you would like the installer to create a Start Menu shortcut
## icon when MATLAB is installed or false if you don't want the shortcut created.
##
## Default value is true.
##
## Set startMenuShortcut value to true or false and
## uncomment the line.

startMenuShortcut=false

## CREATE a MATLAB Startup Accelerator task
##
## The MATLAB Startup Accelerator installer creates a
## system task to preload MATLAB into the system's cache
## for faster startup.
##
## NOTE: By default, a MATLAB Startup Accelerator task will
## automatically be created.
##
## If you want a MATLAB Startup Accelerator task to be created,
## do not edit this section.
##
## Set createAccelTask value to false if you do not want to
## create an Accelerator task and uncomment the line.

createAccelTask=false

################ End - Windows Only Options ################

## SPECIFY PRODUCTS YOU WANT TO INSTALL
##
## By default, the installer installs all the products and
## documentation for which you are licensed. Products you are not licensed for
## are not installed, even if they are listed here.
##
## Note:
## 1. To automatically install all your licensed products, do not edit
##    any lines in this section.
## 
## 2. To install a specific product or a subset of products for
##    which you are licensed, uncomment the line for the product(s) you want
##    to install.

#product.5G_Toolbox
#product.AUTOSAR_Blockset
#product.Aerospace_Blockset
#product.Aerospace_Toolbox
#product.Antenna_Toolbox
#product.Audio_Toolbox
#product.Automated_Driving_Toolbox
#product.Bioinformatics_Toolbox
#product.Communications_Toolbox
#product.Computer_Vision_Toolbox
#product.Control_System_Toolbox
#product.Curve_Fitting_Toolbox
#product.DDS_Blockset
#product.DO_Qualification_Kit
#product.DSP_System_Toolbox
#product.Data_Acquisition_Toolbox
#product.Database_Toolbox
#product.Datafeed_Toolbox
#product.Deep_Learning_HDL_Toolbox
#product.Deep_Learning_Toolbox
#product.Econometrics_Toolbox
#product.Embedded_Coder
#product.Filter_Design_HDL_Coder
#product.Financial_Instruments_Toolbox
#product.Financial_Toolbox
#product.Fixed-Point_Designer
#product.Fuzzy_Logic_Toolbox
#product.GPU_Coder
#product.Global_Optimization_Toolbox
#product.HDL_Coder
#product.HDL_Verifier
#product.IEC_Certification_Kit
#product.Image_Acquisition_Toolbox
#product.Image_Processing_Toolbox
#product.Instrument_Control_Toolbox
#product.LTE_Toolbox
#product.Lidar_Toolbox
#product.MATLAB
#product.MATLAB_Coder
#product.MATLAB_Compiler
#product.MATLAB_Compiler_SDK
#product.MATLAB_Parallel_Server
#product.MATLAB_Production_Server
#product.MATLAB_Report_Generator
#product.MATLAB_Web_App_Server
#product.Mapping_Toolbox
#product.Mixed-Signal_Blockset
#product.Model_Predictive_Control_Toolbox
#product.Model-Based_Calibration_Toolbox
#product.Motor_Control_Blockset
#product.Navigation_Toolbox
#product.OPC_Toolbox
#product.Optimization_Toolbox
#product.Parallel_Computing_Toolbox
#product.Partial_Differential_Equation_Toolbox
#product.Phased_Array_System_Toolbox
#product.Polyspace_Bug_Finder
#product.Polyspace_Bug_Finder_Server
#product.Polyspace_Code_Prover
#product.Polyspace_Code_Prover_Server
#product.Powertrain_Blockset
#product.Predictive_Maintenance_Toolbox
#product.RF_Blockset
#product.RF_Toolbox
#product.ROS_Toolbox
#product.Radar_Toolbox
#product.Reinforcement_Learning_Toolbox
#product.Risk_Management_Toolbox
#product.Robotics_System_Toolbox
#product.Robust_Control_Toolbox
#product.Satellite_Communications_Toolbox
#product.Sensor_Fusion_and_Tracking_Toolbox
#product.SerDes_Toolbox
#product.Signal_Processing_Toolbox
#product.SimBiology
#product.SimEvents
#product.Simscape
#product.Simscape_Driveline
#product.Simscape_Electrical
#product.Simscape_Fluids
#product.Simscape_Multibody
#product.Simulink
#product.Simulink_3D_Animation
#product.Simulink_Check
#product.Simulink_Code_Inspector
#product.Simulink_Coder
#product.Simulink_Compiler
#product.Simulink_Control_Design
#product.Simulink_Coverage
#product.Simulink_Design_Optimization
#product.Simulink_Design_Verifier
#product.Simulink_Desktop_Real-Time
#product.Simulink_PLC_Coder
#product.Simulink_Real-Time
#product.Simulink_Report_Generator
#product.Simulink_Requirements
#product.Simulink_Test
#product.SoC_Blockset
#product.Spreadsheet_Link
#product.Stateflow
#product.Statistics_and_Machine_Learning_Toolbox
#product.Symbolic_Math_Toolbox
#product.System_Composer
#product.System_Identification_Toolbox
#product.Text_Analytics_Toolbox
#product.UAV_Toolbox
#product.Vehicle_Dynamics_Blockset
#product.Vehicle_Network_Toolbox
#product.Vision_HDL_Toolbox
#product.WLAN_Toolbox
#product.Wavelet_Toolbox
#product.Wireless_HDL_Toolbox

到了这里,关于在 Ubuntu 20.04 上静默安装matlab 实践的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Linux学习之Ubuntu 20.04安装5.4.0内核

    参考博客:Ubuntu20.04编译内核教程 sudo lsb_release -a 可以看到我当前的系统是 Ubuntu 20.04.4 , sudo uname -r 可以看到我的系统内核版本是 5.4.0-100-generic 。 sudo apt-get install -y libncurses5-dev flex bison libssl-dev 安装所需要的依赖。 sudo apt-get install linux-source 按两下 Tab ,看一下可以下载的源

    2024年02月06日
    浏览(36)
  • Linux(7)Ubuntu20.04 arm64安装Docker

    vi /etc/apt/sources.list 这个命令后面跟了几个软件包的名字,它们分别是: apt-transport-https:这个软件包允许apt使用HTTPS协议来访问软件源。 ca-certificates:这个软件包提供了一些受信任的证书颁发机构的证书,用来验证HTTPS连接的安全性。 curl:这个软件包提供了一个命令行工具,

    2024年02月10日
    浏览(46)
  • 【Linux】Ubuntu20.04版本安装谷歌中文输入法【教程】

    使用下面的命令行下载 fcitx-googlepinyin 等待下载完成之后,可进行下一步 在菜单中找到 语言支持 第一次打开语言支持,会提示没有安装完全,点击 安装 即可 将键盘默认输入法系统改为 fcitx ,然后 重启系统 选择 配置当前输入法 将 Google拼音 放置在第一位即可完成配置 关闭

    2024年02月03日
    浏览(47)
  • 【WSL】使用WSL在Windows上安装Linux(Ubuntu20.04)

    本文将介绍在win11系统下使用Windows自带的WSL功能安装Ubuntu20.04子系统,其中WSL2本质仍是基于Hyper-V的虚拟机。 Windows11 + WSL2 + Ubuntu20.04 (WSL译为适用于 Linux 的 Windows 子系统) 在Windows设置中添加可选功能,勾选 适用于Linux的Windows子系统(即WSL) 和 虚拟机平台 ,开启该功能需重

    2024年02月12日
    浏览(39)
  • Linux | Ubuntu 20.04安装ipopt和cppAD | 安装全流程+报错解决

    https://github.com/udacity/CarND-MPC-Quizzes/blob/master/install_Ipopt_CppAD.md https://blog.csdn.net/qq_34525916/article/details/119186692#:~:text=%E6%A6%82%E8%A7%88 https://coin-or.github.io/CppAD/doc/install.htm Ubuntu20.04 安装 Ipopt + cppAD流程 coinor库的安装与问题解决 Undefined reference to `Ipopt::IpoptApplication::IpoptApplication(bool,

    2024年02月01日
    浏览(42)
  • Linux桌面端Ubuntu20.04安装和使用netplan修改IP地址

    1. 点击右上角的有线连接: 2. 进入后点击设置按钮:  3. 先点击IPv4,然后选择手动,再在地址处输入想要的IP地址,点击应用,则完成修改。 ​​​​​​ 首先输入: 安装完成后,进入安装文件夹: 打开配置的yaml文件: 进入后一般为空白,配置内容(复制后Ctrl+V): 这

    2024年02月15日
    浏览(42)
  • 交叉编译工具链arm-linux-gnueabihf的安装-ubuntu 20.04

    http://t.csdn.cn/ZbjFX 建议直接在.bashrc文件作修改 ,修改方式相同 ( vi :视自己的编辑器而定) 因为我在修改profile文件后,环境变量生效,但是命令行的用户名等颜色高亮显示会消失;并且重启终端后,又需要再source一下profile。 但是将环境变量添加至.bashrc则不会出现这两个问题

    2024年02月11日
    浏览(34)
  • Linux学习之Ubuntu 20.04在github下载源码安装Openresty 1.19.3.1

    参考的博文:《在 Ubuntu 上使用源码安装 OpenResty》 《OpenResty 安装安装详解-Ubuntu》 《Linux学习之CentOS 7源码安装openresty》 https://openresty.org/en/download.html是官网下载网址,页面往下拉有下载的链接。 https://github.com/openresty/openresty 是github上的链接。 可以点击上图中 tags 进入有不同

    2024年02月11日
    浏览(43)
  • Ubuntu 20.04(linux) cuda(12)+cudnn的deb方式安装以及验证(宝宝也适用哟)

    前言(碎碎念) 想当年在实验室就在自己电脑(双系统)和服务器上都搭建这个环境(Ubuntu18.04+conda+pycharm+cuda+cudnn完整流程) 还写了操作文档,主要遇到了太多问题(比如NVIDIA驱动安装后黑屏问题,真是想用linux之父的话来说一句) 现在再次遇到重装服务器这个事情,又遇

    2024年02月03日
    浏览(88)
  • Ubuntu 20.04 安装宋体

    环境:         ubuntu 20.04,英文环境,但已经安装中文包 检查ubuntu中安装的中文字体 命令: fc-list :lang=zh 检查ubuntu中安装的所有字体 命令: fc-list 宋体下载: Simsun Font - Free Fonts 网盘分享:链接: https://pan.baidu.com/s/12fSpgkUWuWsh-OU32q1WCA 提取码: wpia 或者从win10上拷贝,但是拷贝的

    2024年02月10日
    浏览(35)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包