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.     On the Choose an Amazon Machine Image (AMI) page, choose the following AMI from the Quick Start list: Ubuntu Server 22.04 LTS (HVM), SSD Volume Type, and then choose Select.

4.     On the Choose an Instance Type page, select the g4dn.xlarge type, and choose Next: Configure Instance Details.

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 and G3 instances.

5.     In the Select an existing key pair or create a new key pair dialog: 

a.     Choose Choose an existing pair.

b.     Key pair name: PM_KeyPair.

c.     Choose Launch Instances.

6.     On the Configure Instance Details page, enter the following information:

a.     Network Settings: Choose the PM VPC VPC created in step 4 of "Configuring a VPC".

b.     Advanced Details: Choose the IAM role "PM_RUNFUSER_POLICY" created in "Creating an IAM Policy and Role".

c.     Choose Next: Configure Storage.

7.     On the Add Storage page, enter the following:

a.     Change the default Root volume Size to at least 16 GiB.

Note:    The EBS volumes will incur additional charges. For more information see Amazon EBS Volumes in Amazon’s AWS documentation.

b.     Choose Next: Add Tags.

8.     In the Name and Tags section, enter the following information:

a.     Select Add Tag.

b.     Key: Name.

c.     Value: PM Linux Fuser Initial.

d.     Choose Next: Configure Security Group when you are done.

9.     In the Network Settings section:

a.     Choose Select an existing security group.

b.     Select the PM_SG group.

c.     Choose Review and Launch.

10.  On the Review Instance Launch page, review the details of your instance, and make any necessary changes by clicking the appropriate Edit link. When you are finished, choose Launch.

11.  To launch your instance, select the acknowledgment check box, and then choose Launch Instances

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, choose 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:        A passphrase on a private key is an extra layer of protection. Even if your private key is discovered, it can't be used without the passphrase. The downside to using a passphrase is that it makes automation harder because human intervention is needed 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, choose All Programs, PuTTY, PuTTY).

2.     In the Category pane, choose Session and complete the following fields:

a.     In the Host Name box, to connect using your instance's public DNS, 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, expand SSH, expand Auth, and then choose Credentials. Complete 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 that asks whether you trust the host to which you are connecting. Choose Accept. A window opens and you are connected to your instance.

Customizing the Instance

See: Linux Accelerated Computing Instances in Amazon’s AWS documentation for more information.

1.     To download and install the Nvidia drivers and update the operating system, in the PuTTY terminal window, type:

a.     wget https://us.download.nvidia.com/tesla/535.104.05/NVIDIA-Linux-x86_64-535.104.05.run

b.     sudo apt-get update

c.     sudo apt-get -y install gcc make xserver-xorg libglu1-mesa-dev freeglut3-dev mesa-common-dev libxmu-dev libxi-dev mesa-utils x11vnc xfce4 dkms xvfb  build-essential libglvnd-dev pkg-config

d.     sudo apt-get remove xscreensaver
Type Y when asked to continue.

e.     sudo apt-get remove xscreensaver-data
Type Y when asked to continue.

f.        chmod +x NVIDIA-Linux-x86_64-440.33.01.run

g.     sudo ./NVIDIA-Linux-x86_64-440.33.01.run
Click Yes when asked to register the kernel module. Click OK when prompted to do so during the installation.

h.     sudo reboot
The following message is displayed: "Remote side unexpectedly closed network connection". Click OK.

2.     Right-click the title bar of the PuTTY window, and select Restart Session.

3.     To configure the GPU and start the X window system, in the PuTTY terminal window, type:

a.     nvidia-xconfig --query-gpu-info | grep BusID
Copy the value that is outputted. E.g., if the output is "PCI BusID : PCI:0:30:0", select and copy "PCI:0:30:0".

b.     sudo nvidia-xconfig -a --virtual=1280x1024  --busid=<BUSID>
Where <BUSID> is replaced with the value from 2c above, e.g., sudo nvidia-xconfig -a --virtual=1280x1024  --busid=PCI:0:30:0.

Note:    If a warning is displayed that the xconfig file was not located/opened, click OK.

c.     sudo /usr/bin/X :0 &

d.     export DISPLAY=:0

4.     (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.     xfce4-session &

5.     (Optional) Connect with VNC client using your instance's public DNS and the password set in step 4 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).

6.     To install and configure Wine, do the following:

a.     Open the Start menu and search for cmd to start a command prompt.

b.     Type pscp -i <.ppk file> <wineinst.tar full path>  ubuntu@<fuser IP>:/home/ubuntu/wineinst.tar
Where <.ppk file> is replaced with a full path to the ppk file created in "Convert Your Private Key Using PuTTYgen"; <wineinst.tar full path> is replaced with the full path to the wineinst.tar that is included in the zip folder that can be downloaded from heredownloaded from here; and <fuser IP> is replaced with the Public DNS (IPv4) of the instance.

c.     In the PuTTY terminal window, type:

i.      tar -xvf  wineinst.tar

ii.     sh fuser.sh

Note:    This process can take a few minutes to complete. 

7.     In the Amazon EC2 console, right-click the instance, point to Instance State, and select Stop.

8.     After the instance has stopped, right-click the instance, point to Instance Settings, and select Change Instance Type. The Change Instance Type dialog is displayed.

9.     From the Instance Type dropdown list , select g4ad.4xlarge.

10.  Restart the instance: in the Amazon EC2 console, right-click the instance, point to Instance State, and select Start .

11.  Reconnect to the instance via PuTTY by performing the steps in "Connecting to the Instance".

12.  To download and install AMD drivers, in the PuTTY terminal window type:

a.     sudo apt install awscli

i.      Y to continue

b.     aws s3 cp --recursive s3://ec2-amd-linux-drivers/latest/ .

c.     tar -xf amdgpu-pro*ubuntu*.xz

d.     sudo apt install linux-modules-extra-$(uname -r) -y

e.     Change to the folder of the extracted driver:

i.      Type the following (without pressing ENTER): cd amd

ii.     Press tab once.

iii.    Press ENTER.

f.      cat RPM-GPG-KEY-amdgpu | sudo apt-key add -

g.     ./amdgpu-pro-install -y --opencl=pal,legacy

h.     sudo reboot

13.  The following message is displayed: "Remote side unexpectedly closed network connection". Click OK.

14.  Right-click the title bar of the PuTTY window, and select Restart Session.

15.  Test that the installation was successful:

a.     dmesg | grep amdgpu

b.     Check the response and look for "Initialized amdgpu". This indicates that the installation was successful.

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. Choose Actions, Image and Templates and select Create Image.

2.     In the Create Image dialog, specify values for the following fields, and then choose Create Image.

§  Image name: PM Linux Fuser Image.

3.     While your AMI is being created, you can choose AMIs in the navigation pane to view its status. Initially, this is pending. After a few minutes, the status should change to available.

4.     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.

5.     In the navigation pane, choose Instances and select the PM Linux Fuser Initial instance.

6.     Choose Actions, select Instance State, and then choose Terminate.