This repository shows how to deploy MATLAB® on an Amazon EC2® instance using your Amazon® Web Services (AWS®) account and connect to it using the Remote Desktop Protocol (RDP), SSH, or NICE DCV. The automation uses an AWS CloudFormation template.
For information about the architecture of this solution, see Learn about Architecture. For information about templates, see AWS CloudFormation Templates.
This reference architecture has been reviewed and qualified by AWS.
You need:
- A MATLAB license. For more information, see License Requirements for MATLAB on Cloud Platforms.
- An Amazon Web Services (AWS) account.
- A key pair for your AWS account, in the appropriate region. For more information, see Amazon EC2 Key Pairs.
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, 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.
By default, the MATLAB reference architectures below launch prebuilt machine images, described in Learn about Architecture. Using a prebuilt machine image is the easiest way to deploy a MATLAB reference architecture. Alternatively, to build your own machine image, see Build and Deploy Your Own Machine Image.
To view instructions for deploying the MATLAB reference architecture, select a MATLAB release:
Linux | Windows |
---|---|
R2024b | R2024b |
R2024a | R2024a |
R2023b | R2023b |
R2023a | R2023a |
R2022b | R2022b |
R2022a | R2022a |
R2021b | R2021b |
R2021a | R2021a |
R2020b | R2020b |
R2020a | |
R2019b | |
R2019a_and_older |
The above instructions allow you to launch instances based on the latest prebuilt MathWorks® Amazon Machine Images (AMIs). MathWorks periodically replaces older AMIs with new images. For more details, see When are the MathWorks Amazon Machine Images updated?
For details of the scripts which form the basis of the MathWorks Linux AMI build process, see Build Your Own Machine Image. You can use these scripts to build a custom Linux machine image for running MATLAB on Amazon Web Services. You can then deploy this custom image with the MathWorks infrastructure as code (IaC) templates.
Deploying this reference architecture sets up a single AWS EC2 instance containing MATLAB, a private VPC with an internet gateway, a private subnet, and a security group that opens the appropriate ports for SSH and RDP access.
The Amazon Machine Image (AMI) contains pre-installed drivers and the following software:
- MATLAB, Simulink, toolboxes, and support for GPUs.
- Add-ons: several pretrained deep neural networks for classification, feature extraction, and transfer learning with Deep Learning Toolbox™, including GoogLeNet, ResNet-50, and NASNet-Large.
The following resources will be created as part of the CloudFormation Stack:
- Security Group for SSH and RDP access
- EC2 Instance
The following resources might be created, depending on your deployment configuration:
- IAM role
- A CloudWatch log group
- An elastic IP address
- A SSM document
The links in Deployment Steps launch instances based on the latest MathWorks AMIs for at least the four most recent MATLAB releases. MATLAB releases occur twice each year.
For each MATLAB release, MathWorks periodically replaces the corresponding AMI with a newer AMI that includes the latest MATLAB updates and important security updates of the base OS image.
When MathWorks replaces an AMI, the older AMI is deleted. However, any running instances previously launched from the older AMI are not affected. To continue using an older AMI, copy the AMI into your AWS account. For more details on how to copy an AMI, see How do I copy the AMI? For more details on how to customize the reference architectures to deploy the copied AMI see How do I customize the AMI?
All your files and changes are stored locally on the EC2 Instance. They persist until you either terminate the instance or delete the stack. Stopping the instance does not destroy the data on the instance. If you want your changes to persist outside the stack or before you terminate an instance, you need to:
- Copy your files to another location, or
- Create an image of the virtual machine.
To minimize costs, you might want to shut down the instance when you are not using it. When the virtual machine is stopped, you are only charged for storage. To shut down an EC2 instance, locate it in the AWS web console, select the instance and choose “Instance State/Stop” from the “Actions” menu. You can restart it from the same menu. Any files or changes you make to the virtual machine will persist when you shut it down and will be present when you restart it. Shutting down the virtual machine and restarting it might change the public IP address and DNS name. Inspecting the EC2 instance in the AWS console will reveal the new IP address and DNS name.
To avoid having to change the IP address between restarts, enable the Keep public IP address the same option during deployment. For more information, see (Elastic IP addresses)[https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html].
See Amazon EC2 Service Quotas.
To save an AMI, locate the EC2 Instance in the AWS web console and select Actions > Image > Create Image.
To copy the AMI for a certain MATLAB version to a target region of your choice, follow these steps:
- Choose the MATLAB release that you want to copy from the Releases folder of this repository. Download and open the CloudFormation template .json file for that release.
- Locate the Mappings section in the CloudFormation template. Copy the AMI ID for one of the existing regions, for example, us-east-1.
- To copy the AMI to your target region, see Copy an AMI in the AWS documentation.
- In the Mappings section of the CloudFormation template, add a new RegionMap pair corresponding to your target region. Insert the new AMI ID of the AMI in the target region.
- In your AWS Console, change your region to your target region. In the CloudFormation menu, select the Create Stack > With new resources option. Provide the modified CloudFormation template.
You can now deploy the AMI in your target region using the AMI that you copied.
You can customize a prebuilt AMI by launching the reference architecture, applying changes you want to the EC2 Instance (such as installing additional software, drivers, and files), then saving an image of that instance using the AWS Console. For more information, see How do I save or copy an AMI?. When you create a stack, replace the AMI ID in the CloudFormation template with the AMI ID of your customized image.
You can also create a custom image by building your own using the Packer scripts we provide. See Build and Deploy Your Own Machine Image.
The AMI uses MathWorks Hosted License Manager by default. For information on how to use other license managers, see MATLAB Licensing in the Cloud.
To request assistance or additional features, contact MathWorks Technical Support.
Copyright 2018-2024 The MathWorks, Inc.