MATLAB on EC2 Instructions Guide
Contents Welcome to MATLAB on EC2...3 What You Need to Do...3 Requirements...3 1. MathWorks Account...4 1.1. Create a MathWorks Account...4 1.2. Associate License...4 2. Set Up Your EC2 Environment...4 2.1. Create an AWS Account...4 2.2. Create Key Pair...4 3. Launch an EC2 Instance...5 3.1. Locate MATLAB and Simulink in the AWS Marketplace...5 3.2. Configure an Instance...6 4. Set Up Access to an Instance...9 4.1. Install NX Client...9 4.2. Configure the NX Client...9 5. Start a MATLAB Session...16 5.1. Transfer Data...17 5.1.1. Secure File Transfer Protocol (SFTP)...17 5.1.2. Secure Copy (SCP)...17 5.1.3. FileZilla...18 5.2. Disconnect From MATLAB and Keep the Instance Active...19 5.3. Disconnect From MATLAB and Stop the Instance...19 2
Welcome to MATLAB on EC2 This guide explains how to use MATLAB on the Amazon Elastic Compute Cloud (Amazon EC2). MATLAB on EC2 allows you to access all of your licensed MathWorks products in a fully interactive remote session. It also allows you to take advantage of the powerful computing resources that Amazon EC2 offers (such as the Amazon GPU instance cg1.4xlarge). The most convenient way to access MATLAB on EC2 is through a MATLAB Amazon Machine Image (AMI) on AWS Marketplace. Using the MATLAB AMI, you can launch a Linux instance where MATLAB is installed. What You Need to Do Launching the MATLAB AMI involves a series of steps, the majority of which are one-time set-up procedures. Thereafter, you will be able to access MATLAB on your EC2 instance within a matter of minutes. An overview of the process is shown below. 1. (one-time) MathWorks Account 2. (one-time) Set up EC2 Environment 3. Launch EC2 Instance 4. (once per machine) Set up Instance Access 5. Start MATLAB Session Create a MathWorks Account Create an AWS Account Configure an instance Install NX client Data transfer Associate License Create a key pair Configure NX client Disconnect Requirements To use MATLAB on Amazon EC2, you need: 1. A valid MathWorks Account email address and password. MathWorks uses this information to check your license rights when you start MATLAB. 2. A MathWorks Individual or Group license activated as a Standalone Named User that has the Login Named User feature enabled. Your MathWorks Account must be associated with this license. To enable Login Named User for your license, go to: http://mathworks.com/licensecenter/lnu 3. An uninterrupted connection to the Internet. 4. An Amazon Web Services (AWS) account. For billing purposes, you need to provide credit card information to Amazon when you create your account. 5. An NX Client installed on your computer. The NX Client is the required remote display software for accessing MATLAB on the EC2 instance. 3
1. MathWorks Account 1.1. Create a MathWorks Account If you already have a MathWorks Account, skip this step and go to Step 1.2: Associate License. If you don t have an account, you can create one at the following page: https://www.mathworks.com/accesslogin/createprofile.do 1.2. Associate License If your MATLAB license is already associated with your MathWorks Account, skip this step and go to Step 2: Set up Your EC2 Environment. Please note that your license is needs to meet the license specifications mentioned in the Requirements section. Once you have created your MathWorks Account, you will need to associate your license to it. To do this, follow these steps: 1. Go to the License Center: https://www.mathworks.com/licensecenter 2. Click Add License and follow the instructions. 2. Set Up Your EC2 Environment 2.1. Create an AWS Account If you already have an AWS account, skip this step and go to Step 2.2: Create Key Pair. If you don t have an account, go to: http://aws.amazon.com. For information about pricing, go to http://aws.amazon.com/ec2/pricing/#on-demand. For information about controlling access to AWS Marketplace Subscriptions, go to Controlling Access to AWS Marketplace Subscriptions. 2.2. Create Key Pair To connect to your instance, create a key pair for each user in the AWS Management Console. The key pair validates you as an authorized user. When you create a key pair, you download a.pem file that you import into the NX Client. For information about this process, go to: http://docs.aws.amazon.com/gettingstarted/latest/wah/getting-started-create-key-pair.html 4
3. Launch an EC2 Instance 3.1. Locate MATLAB and Simulink in the AWS Marketplace 1. Log in to the Amazon Marketplace at: https://aws.amazon.com/marketplace 2. Search for MATLAB and Simulink, select the MathWorks image, and click Continue. The Amazon Marketplace page for MATLAB and Simulink looks similar to this: 5
3.2. Configure an Instance 1. On the Launch on EC2 page, select the Version of the software you want to use. 2. Select the Region in which you want to launch your instance. 3. Select the EC2 Instance Type. 4. Select the Key Pair that you created previously. 6
5. Click Accept Terms & Launch with 1-Click. Your instance should start on EC2. You should see a page similar to this: 6. Next to Instance ID, click AWS Management Console. 7
7. In the AWS Management Console, obtain the Public DNS value: a. In the AWS Management Console, click Instances b. Select the instance you just started in step 6. c. Scroll down and copy the Public DNS value. The public DNS value is similar to a machine name. The NX Client uses this string to connect to the instance. This value starts with the characters ec2 and ends with the characters amazonaws.com. 8
4. Set Up Access to an Instance 4.1. Install NX Client Install the NX Client (for Windows, Linux, and Mac OS X 10.x and earlier) on your local computer. Note: To maintain security, the NX technology tunnels all information through the SSH protocol, including the interactive window. To download the Windows version of the OpenNX client, go to: http://sourceforge.net/projects/opennx/files/opennx/ci-win32/nxwin-variant/opennx-0.16.0.725-setup.exe/download To download the Mac version of the OpenNX client, go to: http://sourceforge.net/projects/opennx/files/opennx/ci/opennx-0.16.0.725.dmg/download For Linux versions, follow the instructions mentioned under the Linux Distributions section of the following page: http://opennx.net/download.html 4.2. Configure the NX Client 1. For each instance that you use, you configure the NX Client once. Thereafter, you use the NX Client to connect to your instance directly. 2. On your local computer, start the OpenNX Connection Wizard and click Next. 9
3. Enter session information and click Next: a. Session: Enter a name to identify your MATLAB-EC2 connection b. Host: Enter the Public DNS value you copied from the AWS Management Console. c. Port: Enter 22. d. Internet connection: Select LAN (recommended). For the best experience using NX Client, use a hard-wired Internet connection. 10
4. Enter desktop information and click Next: a. Desktop types: UNIX and GNOME. b. Remote desktop size: Available area. 5. On the authentication screen, click Next. 11
6. Complete the configuration and click Finish. Select Create shortcut on desktop to create a shortcut to the NX Client on your desktop. 12
7. Import the.pem file for the key pair: a. In the displayed menu, click Configure. b. On the General tab, click Key to import the.pem file you downloaded when you created the key pair. 13
8. Click Import and navigate to the location where you downloaded the.pem file. Note: When searching for the.pem file, make sure you select a file type of: Any files (*). 9. Click Save. 10. In the ensuing screen, click Apply and then click OK. 14
11. Enter the login credentials for the NX client and click Login. a. Login: ubuntu b. Password: the instance ID of your EC2 instance. This ID can be determined from the AWS Management console. Notes: Accept the warning about the authenticity of the RSA Key. This login and password are required for the NX client but they do not affect the security of accessing the resources on the Cloud. 12. The NX client configuration steps listed above need to be followed only once after installing the NX client on your machine. For subsequent connections, click Configure and modify the host with the appropriate public DNS value. 15
5. Start a MATLAB Session 1. Use the NX Client to connect to your instance. 2. In the remote display, double-click the MATLAB icon on the desktop. 3. Enter your MathWorks Account email address and password. 16
5.1. Transfer Data To move data between the instance and your local machine, use standard utilities such as SFTP, SCP, or FileZilla. To transfer data, you need: 1. The key pair (.pem file) that you created when you created your AWS Marketplace account. 2. The Public DNS value of your instance. 5.1.1. Secure File Transfer Protocol (SFTP) The SFTP utility is a command-line interactive interface, similar to FTP. It lets you connect to a remote host, navigate its file system, and transfer files. The following example shows how to use SFTP from a UNIX command prompt to transfer the file /home/cloudtmp/emem.mat, to your instance: cd /home/cloudtmp sftp i /home/.ssh/your-key.pem \ ubuntu@ec2-67-202-5-207.computer-1.amazonaws.com:/shared/persisted sftp> put emem.matsftp> ls emem.mat sftp> exit For more information about the SFTP utility, use the following commands: sftp help man sftp 5.1.2. Secure Copy (SCP) The SCP utility lets you access the remote host and transfer the file in a single command. This example shows the UNIX version of the command: scp -i /home/.ssh/your-key.pem emem.mat \ ubuntu@ec2-67-202-5-207.compute-1.amazonaws.com:/shared/persisted For more information about the SCP utility, use the following commands: scp help man scp 17
5.1.3. FileZilla FileZilla is an FTP client that can connect to your EC2 instance and facilitate file transfer through a drag and drop interface. In the following example, assume the file you want to transfer to your instance is: C:\cloudtmp\emem.mat 1. Begin by starting FileZilla, and set its Local site to the folder you want to transfer your local file from (or to). 2. To connect FileZilla to the file system of your instance, use the Quickconnect bar (highlighted). Enter the following information: a. Host: Enter the Public DNS value of the instance. b. Username: The username is always ubuntu. c. Password: Do not provide a password. Instead, do the following: i. Select Edit -> Settings. ii. In the Select panel of the Settings dialog box, choose SFTP. iii. In the Public Key Authentication panel, click Add keyfile. iv. Navigate to your key pair (on Windows, the.pem format key file that you downloaded from your EC2 account is not directly compatible with FileZilla, but when you select the file, FileZilla can automatically convert the format for you). 3. Port: Use port 22 for SFTP connections. 18
4. When FileZilla is configured with the proper key file, click Quickconnect. 5. After connecting, you can drag the emem.mat file from the local column to the remote column. This action completes the transfer. 5.2. Disconnect From MATLAB and Keep the Instance Active You can disconnect from MATLAB and continue to keep your instance active. Amazon continues to charge you for resources until you stop the instance. 1. Close the NX Client window. 2. In the displayed dialog box, select one of these options: Disconnect: Keeps MATLAB and all other programs running, enabling you to use them again when you reconnect with the NX Client. Think of this option as similar to switching off a monitor. End: Closes all running programs but keeps all saved files. Reconnecting after selecting this option is similar to restarting the machine. 5.3. Disconnect From MATLAB and Stop the Instance When you stop the instance, all information stored on the instance is lost. Amazon stops charging you for resources when you stop the instance. 1. Return to the AWS Management Console where you copied the Public DNS. 2. Right click the instance that you created previously. 3. Click Terminate. mathworks.com 2014 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. 80667v02 02/14