Before starting, you will need the following:
- A MATLAB® license that is current on Software Maintenance Service (SMS). For more information, see MATLAB Licensing in the Cloud.
- An Amazon Web Services™ (AWS) account.
- An SSH 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, 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.
The following guide will help you automate the process of running the MATLAB desktop on Amazon Web Services using a Linux virtual machine and connect to it using the Remote Desktop Protocol (RDP). The automation is accomplished using an AWS CloudFormation template. The template is a JSON file that defines the resources needed to run MATLAB on AWS. For information about the architecture of this solution, see Architecture and Resources. For information about templates, see AWS CloudFormation Templates.
- If you don't have an AWS account, create one at https://aws.amazon.com by following the on-screen instructions.
- Use the regions selector in the navigation bar to choose a region supported for the release of MATLAB that you want to deploy.
- Create a key pair in that region. The key pair is necessary as it is the only way to connect to the instance as an administrator.
- If necessary, request a service limit increase for the Amazon EC2 instance type or VPCs. You might need to do this if you already have existing deployments that use that instance type or you think you might exceed the default limit with this deployment.
MATLAB Reference Architecture is released with the twice-yearly general release schedule of MATLAB. To view instructions for deploying the MATLAB reference architecture, select a MATLAB release:
Release |
---|
R2021b |
R2021a |
R2020b |
R2020a |
R2019b |
R2019a_and_older |
Deploying this reference architecture sets up a single AWS EC2 instance containing MATLAB and a security group that opens the appropriate ports for SSH and RDP access.
To make deployment easy, we have prepared an Amazon Machine Image (AMI) running Ubuntu with pre-installed drivers. The AMI contains the following software:
- MATLAB, Simulink, Toolboxes, and support for GPUs.
- Add-Ons: Deep Learning Toolbox(TM) Model for AlexNet Network, Deep Learning Toolbox Model for GoogLeNet Network, and Deep Learning Toolbox Model for ResNet-50 Network
The following resources will be created as part of the CloudFormation Stack:
- Security Group for SSH and RDP access
- EC2 Instance
The following resources may be created according to your deployment configuration:
- IAM role
- A CloudWatch log group
- An elastic IP address
- A SSM document
All your files and changes are stored locally on the virtual machine. They will persist until you either terminate the virtual machine 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’ll need to:
- Copy your files to another location (Example: S3 or Mount an Amazon EBS volume and create a snapshot), or
- Create an image of the virtual machine.
You may want to shut down the instance when you aren’t using it to save some money (you only pay for the storage used by the virtual machine when it is stopped). 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 made to the virtual machine will persist when shutting down and will be there when you restart. A side-effect of shutting down the virtual machine and restarting is that the public IP address and DNS name may change. 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, you can enable the Keep public IP address the same during deployment.
To save a VM image, locate the EC2 Instance in the AWS web console and select Actions > Image > Create Image.
You can copy the AMI for a certain MATLAB version to a target region of your choice.
- In the Releases folder of this repository, choose the MATLAB release that you want to copy. 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, follow the instructions at Copying an AMI on 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 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 VM image by launching the reference architecture, applying any changes you want to the EC2 Instance (such as installing additional software, drivers, and files), and then saving an image of that instance using the AWS Console. For more information, see How Do I save a VM image?. When you create a stack, replace the AMI ID in the CloudFormation template with the AMI ID of your customized image.
The VM image uses MathWorks Hosted License Manager by default. For information on how to use other license managers, see MATLAB Licensing in the Cloud.
If you require assistance or have a request for additional features or capabilities, please contact MathWorks Technical Support.