We're trying to justify using Metaflow on Batch ov...
# ask-metaflow
a
We're trying to justify using Metaflow on Batch over Sagemaker to our users, but one thing we noticed whilst training their model was that Sagemaker is slightly faster. I looked at the average time per epoch (100 epochs), and Batch was 10.67 minutes versus 9.09 minutes for Sagemaker training. The Batch training job on Metaflow is using the
p2.xlarge
instance type and the Sagemaker training job is using the
ml.p2.xlarge
instance type. Configuration for both was set the same. Any clue as to why the Sagemaker training job is slightly faster?
1
a
are you using
@conda
- that can potentially add ~30s to runtime - which shouldn't matter for longer training runs
also,
ml.p2.xlarge
is 25% more expensive than
p2.xlarge
a
Using
@conda_base
, and that's about 3-5 minutes but only counts as overhead at the start
a
correct - are you able to reliably reproduce these numbers over multiple training runs?
also, when running on sagemaker vs batch, how are you controlling for resources?
a
These are long training runs - 20+ hours for both
a
oh - these numbers are per epoch
a
Same configuration, same data, same sample size, same batch size. We are running a controlled experiment I believe
Yup per epoch.
a
what are you specifying with
@resources
?
IIRC with sagemaker, you get the whole instance
a
gpu=1, memory=24000
a
it's likely that the sagemaker instance had access to higher resources -
p2.xlarge
supports 4 vcpus and 60G RAM
you could retry your experiment with
@batch(gpu=1, cpu=4, memory=60000)
a
I see the ec2 instance provisioned by batch and it looks like it has 4 cpus
a
Yes, the ec2 instance has 4 vCPUs but unless you define
cpu=4
in the
@batch
(or
@resources
) decorator, by default the job will only use 1 vcpu
a
Ohhhh - that makes sense. Thanks for clarifying Savin!
among us party 1
a
the performance between ec2 instance through AWS Batch vs Sagemaker should be the same because at the end of the day - it is the very same instance (but lot more expensive on sagemaker).
thankyou 1
a
Got it! Yeah that's what I thought but I didn't know Metaflow only uses a portion of the resources used by the ec2 instance, but yes that makes sense now. I thought the resource decorator helps determine which instance type is selected and then it uses the entirety of that designated instance
a
Ah no - the
@resources
and
@batch
decorator dictate how much resources of a single ec2 instance are allocated to a job. You can fit multiple jobs on a single instance - which will lead to further (and drastic) cost reductions compared to Sagemaker.
👍 1
a
Understood, thanks again Savin!
Hi Savin, We ran another training run with
@batch(gpu=1, cpu=4, memory=60000)
and each epoch still took about 10.6 minutes in comparison to Sagemaker Training's 9.15 minutes per epoch.