Typical workflow
Step 0: Setup AWS credentials (one time)
SpotML uses your AWS credentials to manage the runs for you. You can verify that you have the credentials setup if you see the contents of ~/.aws/credentials
to be something like below.
Secondly, the above access key
IAM user needs to have the permissions to create all the aws resources.
If you are new to AWS, configure your aws cli by going through this setup guide.
Step 1: Install spotml cli (one time)
Step 2: Configure spotml.yaml
First, copy-paste below file in your code root folder.
2. Change the instanceType
to the aws instance you want to run the code on.
Step 3: Create a Docker file (optional)
In the above spotml.yaml
notice that we've used a docker image directly.
But if you want to configure a custom docker container, you can write your own Dockerfile
. See example setup here.
Step 4: Start an instance
This will automatically do the following for you:
Syncs your source code folder to S3
Launch your instance (on-demand or spot instance)
Create a persistent EBS volume and attach it to the above instance.
Setup your docker environment inside the AWS instance
Pulls the code/data from S3 to the EBS volume attached to the instance
The resources created in your AWS account(EBS Volume, EC2 instance, S3 Bucket, Security Groups, etc.) will all have the prefix spotml
.
You should see an output like below once the instance is launched.
Step 5: SSH into the instance
You should see a screen like below. Notice that your source code is already synced into the instance.
You can now run your training command here to kick start a manual training.
Step 6: Schedule a managed run (optional)
If you have a long running training jobs that you only want to run on spot instances, it's a pain to manage them manually.
Configure your script section in
spotml.yaml
file to the command you want
2. Change the spotStrategy
to on-demand
3. Then type below command to let SpotML automatically manage the run.
If the instance is not already running, spotML tries to spawn a new spot instance and runs the above script once the instance is ready.
Note that if a spot instance is not available, spotML backend service keeps trying every 15 mins, until it can spawn the instance. So you can turn off your laptop and do other things, while SpotML tries to schedule the run.
If you intend to cancel the scheduled run, type
Step 7: Check run status (optional)
You can check the status of the instance
, and the run
with the below command.
To also check any logs generated when starting the instance type:
Once you see the run status as RUNNING
from the status
command you can ssh into the actual run session by typing
This opens the tmux
session where spotML ran the train
command.
You can also just ssh into a separate normal ssh session by typing spotml sh
as before for an interactive session.
Last updated