Step 3: Create a Fuser AMI (Linux)
Creating a Linux AMI for a fuser computer is a multi-part step that entails: launching an instance from an existing AMI, customizing the instance, and finally creating a new AMI from the instance.
To create a fuser AMI, follow the steps below. For more information, see: Getting Started with Amazon EC2 Linux Instances in Amazon’s AWS documentation.
Linux fuser AMI’s are generally recommended over Windows AMI’s since Linux instances are more cost effective to run.
Launching an Initial Instance
1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. From the Amazon EC2 console dashboard, choose Launch Instance.
3. In the Name and Tags section, enter Name: PM Linux Fuser Initial.
4. In the Application and OS Images (Amazon Machine Image) section, choose Ubuntu from the Quick Start list (Amazon Machine Image (AMI): Ubuntu Server 24.04 LTS (HVM), SSD Volume Type).
5. In the Instance Type section, select the g4dn.xlarge type.
Note: The instance type selected here depends on the fusers you intend to use to build the project. The g4dn.xlarge instance type should be used to create an AMI for G4, G5 and G6 instances.
6. In the Select Key pair (login) section, choose thefollowing dropdown: Key pair name: PM_KeyPair.
7. In the Network Settings section click EDIT:
a. VPC dropdown: Choose the PM VPC VPC created in step 4 of "Configuring a VPC".
b. Firewall (security groups): Select "Select existing security group" and choose the PM_SG group.
8. In the Configure storage section, do the following:
a. Change the default Root volume Size to at least 70 GiB.
Note: The EBS volumes will incur additional charges. For more information see Amazon EBS Volumesin Amazon’s AWS documentation.
b. Change the Volume Type to General Purpose SSD (gp3).
9. In the Advanced details section, do the following: In the IAM instance profile field, choose the IAM role "PM_RUNFUSER_POLICY" created in "Creating an IAM Policy and Role".
10. To launch your instance, click Launch Instance.
Convert Your Private Key Using PuTTYgen
See: Connecting to Your Linux Instance from Windows Using PuTTY in Amazon’s AWS documentation for more information.
Note: For information on additional ways to connect to your Linux instance, see: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
1. Download and install PuTTY from the PuTTY download page. If you already have an older version of PuTTY installed, we recommend that you download the latest version. Be sure to install the entire suite.
2. From the Start menu -> All Programs -> PuTTY -> PuTTYgen.
3. Under Type of key to generate, choose RSA. If you're using an older version of PuTTYgen, choose SSH-2 RSA.
4. Choose Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, choose the option to display files of all types.
5. Select your .pem file for the key pair that you specified when you launched your instance and choose Open. PuTTYgen displays a notice that the .pem file was successfully imported. Choose OK.
6. To save the key in the format that PuTTY can use, choose Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.
Note: Using a passphrase on a private key adds an additional layer of security. Even if someone gains access to your private key, they cannot use it without the passphrase. However, the downside of using a passphrase is that it makes automation harder because manual input is required to log on to an instance, or to copy files to an instance.
7. Specify the same name for the key that you used for the key pair (for example, PM_KeyPair) and choose Save. PuTTY automatically adds the .ppk file extension.
Your private key is now in the correct format for use with PuTTY. You can now connect to your instance using PuTTY's SSH client.
Connecting to the Instance
To connect:
1. Start PuTTY (from the Start menu -> All Programs -> PuTTY -> PuTTY).
2. In the Category pane, choose Session and complete the following fields:
a. To connect using your instance's public DNS, in the Host Name box, enter ubuntu@public_dns_name.
You can get the public DNS for your instance using the Amazon EC2 console. Check the Public DNS (IPv4) column. If this column is hidden, choose the Show/Hide icon and select Public DNS (IPv4).
b. Ensure that the Port value is 22.
c. Under Connection type, select SSH.
3. (Optional) You can configure PuTTY to automatically send 'keepalive' data at regular intervals to keep the session active. This is useful to avoid disconnecting from your instance due to session inactivity. In the Category pane, choose Connection, and then enter the required interval in the Seconds between keepalives field. For example, if your session disconnects after 10 minutes of inactivity, enter 180 to configure PuTTY to send keepalive data every 3 minutes.
4. In the Category pane, expand Connection >SSH > Auth > choose Credentials. Enter the following:
a. In the Private key file for authentication field, choose Browse.
b. Select the .ppk file that you generated for your key pair and choose Open.
c. (Optional) If you plan to start this session again later, you can save the session information for future use. Under Category, choose Session, enter a name for the session in Saved Sessions, and then choose Save.
d. Choose Open.
5. If this is the first time you have connected to this instance, PuTTY displays a security alert dialog asking whether you trust the host to which you are connecting. Choose Accept. A window opens and you are connected to your instance.
6. Enter the username defined in the AMI used to launch the instance. If you didn't define a custom username, use the default username, ubuntu.
Customizing the Instance
See: Linux Accelerated Computing Instances in Amazon’s AWS documentation for more information.
1. Add 32-bit support and update the instance: In the PuTTY terminal window, type:
sudo dpkg --add-architecture i386
sudo apt-get -y update
sudo apt-get -y upgrade
2. Download all necessary packages, drivers and software (This step can take a while): In the PuTTY terminal window, type:
sudo apt-get -y install pkg-config unzip x11vnc xterm fvwm dkms xserver-xorg xvfb ubuntu-drivers-common cifs-utils nvidia-driver-565-server wine winetricks winbind mesa-utils
3. Restart the instance:
sudo reboot
The following message is displayed: "Remote side unexpectedly closed network connection". Click OK.
4. Right-click the title bar of the PuTTY terminal window, and select Restart Session.
5. (Optional) To test the successful Nvidia driver installation, in the PuTTY terminal window, type:
nvidia-smi
6. To configure the GPU and start the X window system, in the PuTTY terminal window, type:
sudo nvidia-xconfig -a
sudo /usr/bin/X :0 &
export DISPLAY=:0
7. (Optional) To configure VNC in order to verify X runs properly, in the PuTTY terminal window type:
a. x11vnc -storepasswd Then type and verify the password.
b. y
This confirms writing the password to /home/Ubuntu/.vnc/passwd.
c. x11vnc -rfbauth ~/.vnc/passwd &
d. fvwm &
8. (Optional) Connect with VNC client using your instance's public DNS and the password set in step 7 above.
You can get the public DNS for your instance using the Amazon EC2 console. Check the Public DNS (IPv4) column. If this column is hidden, choose the Show/Hide icon and select Public DNS (IPv4).
9. To configure Wine, do the following:
a. Click the Start
button, type "cmd", and then select Command Prompt from the list.
b. In the command prompt window type the following and click Enter:
pscp -i <.ppk file> <wineinst.tar full path> ubuntu@<fuser IP>:/home/ubuntu/wineinst.tar
· Replace <.ppk file> with the full path to the ppk file you created in "Convert Your Private Key Using PuTTYgen."
· Replace < wineinst.tar full path> with the full path to the wineinst.tar file included in the zip folder that can be downloaded from here.
· Replace <fuser IP> with the Public DNS (IPv4) of the instance.
c. In the PuTTY terminal window, type:
tar -xvf wineinst.tar
sh fuser.sh
Note: This process can take a few minutes to complete.
10. Once finished, shutdown the instance:
sudo shutdown -h now
Saving a Fuser AMI
See: Creating an Amazon EBS-Backed Linux AMI in Amazon’s AWS documentation for more information.
1. In the navigation pane, choose Instances and select the PM Linux Fuser Initial instance.
2. Click the instance ID to display the Instance summary screen.
3. Click the Storage tab and click the volume ID.
4. Select the volume. Then from the Actions dropdown list at the top left, select Create snapshot.
5. In the description, enter PM Linux Fuser Initial snapshot (this process takes several minutes).
6. Notice the green ribbon at the top of the screen, and click the ID of the snapshot which is being created.
7. Copy the snaphshot ID.
8. Use the following command in CloudShell to create a new AMI. Replace <Snapshot_ID> with the one copied in the previous step:
aws ec2 register-image \
--name "PM Linux Fuser Image" \
--root-device-name "/dev/sda1" \
--block-device-mappings "DeviceName=/dev/sda1,Ebs={SnapshotId=<Snapshot_ID>,VolumeType=gp3}" \
--architecture x86_64
9. Close CloudShell.
10. Choose AMIs in the navigation pane and record the AMI ID of the created AMI, or copy it to the clipboard. You need this AMI ID for PhotoMesh to launch fuser instances.
11. In the navigation pane, choose Instances and select the PM Linux Fuser Initial instance.
12. Choose Actions, select Instance State, and then choose Terminate.