YUFENG GUO: Are you looking to run machine
learning on Docker containers in the cloud, future proofing
your workflow and allowing you to use
any library of your choice?
If so, then you've come to the right place.
Because today, we're going to run custom containers
on Google Cloud AI Platform.
[TONES]
Welcome to "AI Adventures," where
we explore the art, science, and tools of machine learning.
My name is Yufeng Guo.
And on this episode, we're going to use AI Platform's custom
containers to see how to run custom training jobs on Google
Cloud using Docker containers.
This approach gives us a number of key benefits.
First is faster start up time.
If you use a custom container with all of your dependencies
preinstalled, you can save the time
that your training application would otherwise
take to install those dependencies when starting up.
So that gives you faster training and fewer network
and compute resources used.
Second, you can use any machine learning framework you want.
Just install your chosen framework
in your custom container and then just
use it to run those jobs on AI Platform.
This not only means you can use every tool under the sun,
but it also future proofs your workflow,
allowing you to easily switch libraries or add
new ones for experimentation.
Third-- and this is a little bit related to the previous point--
you can use the latest build of a library.
Or if you want an older version--
if that's what you're relying on--
that's great too.
No one will force you to update if you're not ready.
It's your container.
It's also worth pointing out that since you're
building your own container image,
that if you want a certain functionality,
you're going to have to install it.
So if you want something like hyperparameter tuning or GPU
support, you'll need to make sure to include
the necessary libraries to make those features work.
OK.
Let's look at how you can use custom containers
to train a model.
We're going to try to use PyTorch to train on MNIST,
just to show off the tooling and process.
First things first, we've got to create the container.
Now I know that some parts of the data science community
are a bit against learning yet another tool to do their work.
But I'm hoping that you're here to learn new things.
Plus, it definitely seems like containers are here to stay.
So it will be really useful to learn this tool.
Our Dockerfile installs PyTorch, Cloud ML Hypertune,
and downloads gsutil for exporting cloud storage.
And then it configures some PATs.
Finally, it copies in the training code
and then sets it up to run right when
the container starts executing.
Be sure to test your Dockerfile locally
before you use it by building that image and running it.
Then, you can push it off to Google Container Registry,
or GCR.
That's where AI Platform will look for your image
during the training job.
Once you have your image uploaded to GCR, creating a job
is quite similar to normal usage of AI Platform Training.
There's just one extra command line argument when
you submit that training job.
You want to make sure you include --master-image-uri
and pass in that GCR URI.
At this point you might be wondering,
why go through all the trouble of building a Docker
image if we could just run the training locally?
There is a couple of scenarios, I can imagine,
where this would be particularly useful.
Perhaps your data is larger than your machine's storage
or the data set is secured behind permissions
so you can't run the full training
job on a local machine.
Or maybe the compute resources of your local machine
just aren't adequate because you need
something like multiple GPUs.
Third reason might be that you want
to do distributed training across many machines,
or you want to run many jobs in parallel to each other,
or you just really like working with containers.
Hey, that's always a possibility.
For those who need containers, AI Platform Training
with custom containers provides a great new set of features
and functionality to explore.
I can't wait to hear about how you containerize your model.
Thanks for watching this episode of Cloud "AI Adventures."
And if you enjoyed it, click that Like button
and be sure to subscribe to get all the latest episodes right
when they come out.
For now, check out AI Platform Custom Containers for all
your custom training needs.
[MUSIC PLAYING]