Skip to content

Commit c2f09cd

Browse files
committed
R2025b release!
1 parent e0697ee commit c2f09cd

File tree

89 files changed

+191342
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+191342
-60
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ You are responsible for the cost of the AWS services you use when you create clo
2525

2626
# Deployment Steps
2727

28+
By default, the MATLAB Parallel Server reference architectures below launch prebuilt machine images, described in [Learn about Cluster Architecture](#learn-about-cluster-architecture).
29+
Using a prebuilt machine image is the easiest way to deploy a MATLAB Parallel Server reference architecture.
30+
Prebuilt images are provided for the five most recent MATLAB releases.
31+
Alternatively, to build your own machine image,
32+
see [Build and Deploy Your Own Machine Image](#build-and-deploy-your-own-machine-image).
33+
You can also use this workflow to install an earlier MATLAB release.
34+
35+
## Deploy Prebuilt Machine Image
36+
2837
To view instructions for deploying the MATLAB Parallel Server reference architecture, select a MATLAB release:
2938

3039
| Linux | Windows |
@@ -45,6 +54,24 @@ To view instructions for deploying the MATLAB Parallel Server reference architec
4554
| [R2019a\_and\_older](releases/R2019a_and_older/README.md) | |
4655

4756

57+
The above instructions allow you to launch instances based on the latest prebuilt MathWorks® Amazon Machine Images (AMIs).
58+
59+
## Build and Deploy Your Own Machine Image
60+
61+
For details of the scripts which form the basis of the MathWorks Linux AMI build process,
62+
see [Build Your Own Machine Image](./packer/v1).
63+
You can use these scripts to build a custom Linux machine image for running MATLAB Parallel Server on Amazon Web Services.
64+
You can then deploy this custom image with the MathWorks infrastructure as code (IaC) templates.
65+
66+
You can customize the MATLAB release which is installed as part of this custom build.
67+
This includes MATLAB releases supported by the prebuilt images, as well as earlier MATLAB releases.
68+
For more details,
69+
see [Customize MATLAB Paralle Server Release to Install](./packer/v1#customize-matlab-parallel-server-release-to-install).
70+
71+
Platform engineering teams can use these scripts to take advantage of optimizations MathWorks has developed
72+
for running MathWorks products in the cloud.
73+
For more details, see [What are the advantages of building images with MathWorks scripts?](#what-are-the-advantages-of-building-images-with-mathworks-scripts)
74+
4875
# Learn About Cluster Architecture
4976

5077
This diagram illustrates the cluster architecture created by the template. When you use the [AWS CloudFormation templates](https://aws.amazon.com/cloudformation/) in this repository, it creates the [MATLAB Job Scheduler](#what-is-matlab-job-scheduler) and the following resources. For more information about each resource, see [AWS CloudFormation template reference.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-reference.html)
@@ -135,6 +162,17 @@ Before enabling Spot Instances, consider these three aspects:
135162

136163
* Parameters for the VPC and subnet in this CloudFormation template: Each Availability Zone in a region has a different capacity available for Spot Instances. To increase the likelihood of obtaining Spot Instances for your cluster, ensure that your VPC has subnets in multiple Availability Zones in the region.
137164

165+
### What are the advantages of building images with MathWorks scripts?
166+
167+
Images built with MathWorks scripts are optimized and tested for MathWorks workflows.
168+
The images are deployed by MathWorks CloudFormation templates following AWS best practices.
169+
170+
The warmup scripts found in [startup](./packer/v1/startup) allow you to start MATLAB faster. The CloudFormation template uses these scripts to automatically initialize MathWorks files on the instance. These scripts are automatically included in both the prebuilt images and the images that you build using the instructions in [Deployment Steps](#deployment-steps).
171+
172+
Without the optimization scripts, starting a large software application, such as MATLAB, for the first time can potentially take tens of minutes. Subsequent starts of the large software application will be faster. This is because AWS initializes the storage for the EC2 instance, as described in [Initialize Amazon EBS volumes](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-initialize.html).
173+
174+
Other scripts in this repo also ensure that all the necessary MATLAB dependencies are installed, and make it easy to build an image with an older MATLAB release.
175+
138176
# Technical Support
139177
If you require assistance or have a request for additional features or capabilities, contact [MathWorks Technical Support](https://www.mathworks.com/support/contact_us.html).
140178

packer/v1/.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Shell scripts are run by the Packer build on the remote Linux machine,
2+
# and so should have LF line endings on checkout.
3+
*.sh text eol=lf

packer/v1/README.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# **Build Your Own Machine Image**
2+
3+
## **Introduction**
4+
This guide shows how to build your own Amazon® Machine Image (AMI) using the same scripts that form the basis of the build process for MathWorks® prebuilt images.
5+
You can use the scripts to install MATLAB® Parallel Server™, MATLAB toolboxes, and the other features detailed below.
6+
7+
A HashiCorp® Packer template generates the machine image.
8+
The template is an HCL2 file that tells Packer which plugins (builders, provisioners, post-processors) to use, how to configure each of those plugins, and what order to run them in.
9+
For more information about templates, see [Packer Templates](https://www.packer.io/docs/templates#packer-templates).
10+
11+
12+
13+
## **Requirements**
14+
Before starting, you will need:
15+
* A valid Packer installation later than 1.7.0. For more information, see [Install Packer](https://www.packer.io/downloads).
16+
* AWS credentials with sufficient permission. For more information, see [Packer Authentication](https://www.packer.io/plugins/builders/amazon#authentication).
17+
18+
## **Costs**
19+
You are responsible for the cost of the AWS services used when you create cloud resources using this guide. Resource settings, such as instance type, will affect the cost of deployment. For cost estimates, see the pricing pages for each AWS service you will be using. Prices are subject to change.
20+
21+
## **Quick Launch Instructions**
22+
This section shows how to build the latest MATLAB Parallel Server machine image in your own AWS account.
23+
24+
Pull the source code and navigate to the Packer folder.
25+
```bash
26+
git clone https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws
27+
cd matlab-parallel-server-on-aws/packer/v1
28+
```
29+
30+
Initialize Packer to install the required plugins.
31+
You only need to do this once.
32+
For more information, see [init command reference (Packer)](https://developer.hashicorp.com/packer/docs/commands/init).
33+
```bash
34+
packer init build-parallel-server-ami.pkr.hcl
35+
```
36+
37+
Launch the Packer build with the default settings.
38+
```bash
39+
packer build build-parallel-server-ami.pkr.hcl
40+
```
41+
Packer writes its output, including the ID of the generated machine image, to a `manifest.json` file at the end of the build.
42+
To use the built image with a MathWorks CloudFormation template, see [Deploy Machine Image](#deploy-machine-image).
43+
44+
45+
## **How to Run the Packer Build**
46+
This section describes the complete Packer build process and the different options for launching the build.
47+
48+
### **Build-Time Variables**
49+
The [Packer template](https://github.mathworks.com/development/parallel-server-aws-refarch/tree/dev/packer/v1/build-parallel-server-ami.pkr.hcl) supports these build-time variables.
50+
| Argument Name | Default Value | Description |
51+
|---|---|---|
52+
| [PRODUCTS](#customize-products-to-install)| MATLAB, MATLAB Parallel Server, MATLAB Production Server™, and all available toolboxes | Products to install, specified as a list of product names separated by spaces. For example, `MATLAB Simulink MATLAB_Parallel_Server MATLAB_Production_Server`.<br>MATLAB parallel server must be installed with MATLAB in order to deploy a parallel server cluster to the cloud. If no products are specified, the Packer build will install MATLAB with all available toolboxes. For more information, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).|
53+
| [POLYSPACE_PRODUCTS](#customize-polyspace-products-to-install)| Polyspace® Bug Finder™ Server™ and Polyspace Code Prover™ Server™ | Polyspace products to install, specified as a list of product names separated by spaces. For example, `Polyspace_Bug_Finder_Server Polyspace_Code_Prover_Server`.<br/>If no products are specified, the Packer build will install Polyspace with Polyspace Bug Finder Server and Polyspace Code Prover Server. For more information, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).|
54+
| SPKGS | List of Deep Learning Support Packages, specified in [release-config](https://github.mathworks.com/development/parallel-server-aws-refarch/tree/dev/packer/v1/release-config) | A list of support packages to install, specified as a list of support package names separated by spaces. For example, `Deep_Learning_Toolbox_Model_for_GoogLeNet_Network Deep_Learning_Toolbox_Model_for_ResNet-101_Network` |
55+
| BASE_AMI | Default AMI ID refers to ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server. | The base AMI upon which the image is built, defaults to an official Canonical® Ubuntu® image. |
56+
| VPC_ID | *unset* | VPC to assign to the Packer build instance. If no VPC is specified, the default VPC will be used.|
57+
| SUBNET_ID | *unset* | Subnet to assign to the Packer build instance. If no subnet is specified, the subnet with the most free IPv4 addresses will be used.|
58+
| INSTANCE_TAGS |{Name="Packer Builder", Build="MATLAB_Parallel_Server"} | Tags to add to the Packer build instance.|
59+
| AMI_TAGS | {Name="Packer Build", Build="MATLAB_Parallel_Server", Type="matlab-parallel-server-on-aws"} | Tags to add to the machine image.|
60+
61+
For a full list of the variables used in the build, see the description fields in the
62+
[Packer template](https://github.mathworks.com/development/parallel-server-aws-refarch/tree/dev/packer/v1/build-parallel-server-ami.pkr.hcl).
63+
64+
65+
66+
### **Customize Packer Build**
67+
#### **Customize Products to Install**
68+
Use the Packer build-time variable `PRODUCTS` to specify the list of products you want to install on the machine image. If unspecified, Packer will install MATLAB, MATLAB Parallel Server, MATLAB Production Server, and all the available toolboxes. Use the Packer build-time variable `POLYSPACE_PRODUCTS` to specify the list of Polyspace products you want to install on the machine image. If unspecified, Packer will install Polyspace Bug Finder Server and Polyspace Code Prover Server.
69+
70+
For example, install the latest version of MATLAB and Deep Learning Toolbox.
71+
```bash
72+
packer build -var="PRODUCTS=MATLAB MATLAB_Parallel_Server MATLAB_Production_Server Deep_Learning_Toolbox" build-parallel-server-ami.pkr.hcl
73+
```
74+
75+
#### **Customize MATLAB Parallel Server Release to Install**
76+
To use an earlier MATLAB Parallel Server release, you must use one of the variable definition files in the [release-config](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws/tree/master/packer/v1/release-config) folder. Although the files are available for MATLAB Parallel Server release R2021b and later, MathWorks recommends using MATLAB Parallel Server R2023a or later. This is because the Packer builds for earlier releases use Ubuntu 20.04, which is no longer supported by Canonical.
77+
78+
For example, install R2023a for MATLAB Parallel Server and all necessary and available toolboxes.
79+
```bash
80+
packer build -var-file="release-config/R2023a.pkrvars.hcl" build-matlab-parallel-server-ami.pkr.hcl
81+
```
82+
Command line arguments can also be combined. For example, install R2020a for MATLAB, MATLAB Parallel Server, MATLAB Production Server, and the Parallel Computing Toolbox only.
83+
```bash
84+
packer build -var-file="release-config/R2023a.pkrvars.hcl" -var="PRODUCTS=MATLAB MATLAB_Parallel_Server MATLAB_Production_Server Parallel_Computing_Toolbox" build-matlab-parallel-server-ami.pkr.hcl
85+
```
86+
Launch the customized image using the corresponding CloudFormation Template.
87+
For instructions on how to use CloudFormation Templates, see the Deployment Steps
88+
section on [MATLAB Parallel Server on Amazon Web Services](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws).
89+
#### **Customize Multiple Variables**
90+
You can set multiple variables in a [Variable Definition File](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#standard-variable-definitions-files).
91+
92+
For example, to generate a machine image with the most recent MATLAB installed with necessary and additional toolboxes in a custom VPC, create a variable definition file named `custom-variables.pkrvars.hcl` containing these variable definitions.
93+
```
94+
VPC_ID = <any_VPC_id>
95+
PRODUCTS = "MATLAB MATLAB_Parallel_Server MATLAB_Production_Server Deep_Learning_Toolbox Parallel_Computing_Toolbox"
96+
POLYSPACE_PRODUCTS = "Polyspace_Bug_Finder_Server Polyspace_Code_Prover_Server"
97+
```
98+
99+
To specify a MATLAB release using a variable definition file, modify the variable definition file
100+
in the [release-config](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws/tree/master/packer/v1/release-config)
101+
folder corresponding to the desired release.
102+
103+
Save the variable definition file and include it in the Packer build command.
104+
```bash
105+
packer build -var-file="custom-variables.pkrvars.hcl" build-parallel-server-ami.pkr.hcl
106+
```
107+
108+
### **Installation, Runtime, and Startup Scripts**
109+
The Packer build executes scripts on the image builder instance during the build.
110+
These scripts perform tasks such as
111+
installing tools needed by the build (including gcc, wget, make, CloudWatch, cfn-signal),
112+
installing MATLAB Parallel Server and toolboxes on the image using [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md),
113+
and cleaning up build leftovers (including bash history, SSH keys).
114+
115+
For the full list of scripts that the Packer build executes during the build, see the `BUILD_SCRIPTS` parameter in the
116+
[Packer template](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws/tree/master/packer/v1/build-parallel-server-ami.pkr.hcl).
117+
The prebuilt images that MathWorks provides are built using these scripts as a base, and additionally have support packages installed.
118+
119+
In addition to the build scripts above, the Packer build copies further scripts to the machine image,
120+
to be used during startup and at runtime. These scripts perform tasks such as
121+
mounting available storage,
122+
initializing CloudWatch logging (if this is chosen),
123+
performing MATLAB startup acceleration,
124+
setting up [MATLAB Job Scheduler](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws?tab=readme-ov-file#what-is-matlab-job-scheduler),
125+
and setting up autoscaling scripts and cluster management scripts,
126+
among other utility tasks.
127+
128+
For the full list of startup and runtime scripts, see the `STARTUP_SCRIPTS` and the `RUNTIME_SCRIPTS` parameters in the
129+
[Packer template](https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws/tree/master/packer/v1/build-parallel-server-ami.pkr.hcl).
130+
131+
132+
## Validate Packer Template
133+
To validate the syntax and configuration of a Packer template, use the `packer validate` command. This command also checks whether the provided input variables meet the custom validation rules defined by MathWorks. For more information, see [validate Command](https://www.packer.io/docs/commands/validate#validate-command).
134+
135+
You can also use command line interfaces provided by Packer to inspect and format the template. For more information, see [Packer Commands (CLI)](https://www.packer.io/docs/commands).
136+
137+
## Deploy Machine Image
138+
When the build finishes, Packer writes
139+
the output to a `manifest.json` file, which contains these fields:
140+
```json
141+
{
142+
"builds": [
143+
{
144+
"name":,
145+
"builder_type": ,
146+
"build_time": ,
147+
"files": ,
148+
"artifact_id": ,
149+
"packer_run_uuid": ,
150+
"custom_data": {
151+
"release": ,
152+
"specified_products": ,
153+
"specified_spkgs": ,
154+
"specified_polyspace_products": ,
155+
"build_scripts": ,
156+
}
157+
}
158+
],
159+
"last_run_uuid": ""
160+
}
161+
```
162+
163+
The `artifact_id` section shows the ID of the machine image generated by the most recent Packer build.
164+
165+
The CloudFormation templates provided by MathWorks for releases R2022b onwards include an optional custom machine image ID field, `CustomAmiId`.
166+
If you do not specify a custom machine image ID, the template
167+
launches a prebuilt image provided by MathWorks. To launch a custom machine image,
168+
provide the `artifact_id` from the `manifest.json` file as the `CustomAmiId`.
169+
170+
For AMIs built with an earlier MATLAB release, replace the AMI ID in the
171+
corresponding CloudFormation template with the AMI ID of your customized image.
172+
173+
If the build has been customized, for example by removing or modifying one or more of the included scripts,
174+
the resultant machine image **may no longer be compatible** with the provided CloudFormation template. If the AMI has been created from the MATLAB on AWS offering, then the resultant machine image **may not be compatible** due to missing autoscaling scripts, job scheduler setup, and other customisations.
175+
Compatibility can in some cases be restored by making corresponding modifications to the CloudFormation template.
176+
177+
## Technical Support
178+
If you require assistance or have a request for additional features or capabilities, contact [MathWorks Technical Support](https://www.mathworks.com/support/contact_us.html).
179+
180+
----
181+
182+
Copyright 2025 The MathWorks, Inc.
183+
184+
----

0 commit comments

Comments
 (0)