%reload_ext autoreload
%autoreload 2
%matplotlib inline
from aws_setup import *
name='fast-ai'
vpc = create_vpc(name)
create_ec2_keypair(name)
ec2
instance_name = f'{name}-instance'
instance_type = 't2.micro'
spot_prices = get_spot_prices(); spot_prices[instance_type]
launch_specs = LaunchSpecs(vpc, instance_type=instance_type).build()
instance = create_spot_instance(instance_name, launch_specs); instance
Waiting on spot fullfillment... Fullfillment completed. InstanceId: i-09602f7331bed103c Rebooting...
Request on demand instance (if spot error)
# instance = create_instance(instance_name, vpc, instance_type='t2.micro'); instance
instance = get_instance(f'{instance_name}'); instance
ec2.Instance(id='i-09602f7331bed103c')
volume_tag = f'{name}-ebs-volume'
volume = create_volume(volume_tag, size=100)
_ = attach_volume(instance, volume_tag, device='/dev/xvdf')
efs_tag = f'{name}-efs'
efs = create_efs(efs_tag, vpc)
client = connect_to_instance(instance)
Connecting to SSH... Connected!
upload_path = Path.cwd()/'upload_scripts/mount_ebs.sh'
upload_file(client, str(upload_path), 'mount_ebs.sh')
out, _ = run_command(client, 'chmod 755 mount_ebs.sh')
run_command returned:
out, _ = run_command(client, './mount_ebs.sh --device /dev/xvdf') # no reformatting
# out, _ = run_command(client, './mount_ebs.sh --device /dev/xvdf --reformat true')
run_command returned:
mount: /dev/xvdf is already mounted or /home/ubuntu/ebs_mount busy
/dev/xvdf is already mounted on /home/ubuntu/ebs_mount
efs_addr = get_efs_address('fast-ai-efs'); efs_addr
out, _ = run_command(client, 'mkdir ~/efs_mount')
run_command returned:
efs_mount_cmd = f'sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 {efs_addr}:/ ~/efs_mount'
out, _ = run_command(client, efs_mount_cmd)
run_command returned: