All right.
So first of all I'm going to take my mouse.
I'm going to hover around here.
I'm going to press the plus code button.
It's very like cursor.
Uh and I'm going to go here and type two plus two and hold down shift and press enter.
And we just used a Tesla T4 machine, uh, on the cloud in order to do this important operation.
Uh, and, you know, we can we can do bananas.
Uh, and uh, there we go.
We get we get bananas.
Um, and, um, yes, you you can imagine all the other great things we could do.
Uh, a lot of stuff comes installed automatically on radios that you don't even need to pip install.
So I can do like import gradio as GR.
And I think that will just run.
Doesn't need anything installed.
Gradio just comes on the box.
So it's as slow as it is on my machine.
Look at that.
Uh, you get used to this.
Obviously that's the stop button.
You can press the stop at any point if it's taking too long.
But it did finish.
Um, if you need to pip install something you can't just do like pip install pip install requests or
something.
Uh, you would have to put an exclamation mark in front of it, which is a way of saying don't run this
as Python, run this as an underlying shell command.
That's what that would do.
But for this notebook we don't need to do any Pip installs.
Everything is good to go.
The first thing we're going to do is a little bit of code here.
Uh, to check the GPU of this code, of this box, whatever this is running on out in the cloud by calling
this this shell command Nvidia SMI to get the GPU info and find out what it is and print it if it is
a Tesla T4.
Let's run this code.
Bam!
Here's the results.
It is indeed an Nvidia chip.
And there we go.
It is a Tesla T4.
Good to know.
And it has 15MB on it.
And that makes sense because we can see just over here it does indeed, according to Colab, have that
as well.
So the code that's running is giving us a consistent story.
That's good to see.
Okay, next up comes the most important thing we're doing today.
Pay attention please.
There's a fiddly thing to do now.
One fiddly thing one time only and then fiddly ness is over.
Okay, we need to connect this colab to our hugging face account, and in fact, we're connecting any
colab when we're logged in by using a feature that's secrets that are built into colab.
And this is the alternative to the EMV file.
You don't have a dot env file on Colab because we don't.
It's not on our file system, it's out in the cloud.
Here's how it works.
First of all, you need to have got yourself a hugging face account, which you did in the last video
or two videos ago.
So you're good there.
Thank you.
You you you listen to me.
So at this point, please.
Let's go to your hugging face account.
Here.
I have mine open, conveniently hugging face.
So this is me signed in, and, uh, you go to your avatar, you go to your profile.
That is my hugging face profile.
And I have two notifications.
I don't know what they are.
Uh, here are his his, my two apps and some fun things from another course.
Uh, and, uh, then you come along here and you go to settings.
So you're looking at your avatar page, you press settings and you go to API to access tokens.
Access tokens.
This page here, look at this.
Now here is the thing.
Here is the thing.
Listen up.
You press create new token.
Here comes the new token.
You see this page for the new token.
The next thing you do is you find this word right.
You need to press that word right and give it a token name.
Give it whatever token name you like.
This can be, you know, my my favorite token.
And then you press Create token.
Now the reason you need to write permissions is first of all that gives you access to download models
from from any repo which you'll need when we download open source models.
But also we are going to be writing our own models at future weeks.
And if you don't have this permission, it will cause lots of troubles later.
So do have write permissions.
Give it a name, create the token and copy it into your clipboard.
It should start h underscore and that should now be in your clipboard.
And now we go back to Colab okay.
And in Colab you now go to the left here to this little key, and you press the key and it opens up
this thing that says secrets and secrets are they are just like the dot env file.
They have a name and a value, just like the dot env file has something equals something.
And the name for hugging face is underscore token.
And in that value cell you paste the the lowercase HF underscore and that key.
And you put in exactly as it is with no spaces and no nothing random on the beginning or end, just
as it should be, so that you have that in there and you make sure it's switched on here for notebook
access, which means that this notebook here will have access to that secret.
And once you've done that, you're golden.
You've done the fiddly part.
You can now access this hugging face token from your code, and it even tells you right there that it's
super simple over here to have access to any of these keys with code that looks a bit like that, but
instead of secret name, you would put this word here, that word would go there, and then you'd be
able to access this value.
It's just a way to have secrets stored separately.
And these secrets here are associated with your Google account.
If you share this with someone else, they won't get access to your secrets.
The secrets, of course, are secret to you.
And as an added benefit, anytime you're logged in, you'll have access to all of these secrets, which
makes it super convenient.
It's like a EMV file that's everywhere on Google Colab for you and only for you when you're logged in.
So that's the fiddly part.
Done, sorted.
You've got it set up.
Brilliant.
Let's go on.
Okay.
Game time.
You've filled in your secrets.
You've connected to a T4.
You're looking all good there.
Scroll down.
So first of all, this is exactly the code that you may remember you saw just here.
It's the code which is going to allow us to access our HRF token.
And it's going into a something called HRF token, a variable called that.
And that's coming from Google Colab importing user data.
So user data is basically the secrets on the left.
We're getting HRF token and there it is.
And then we're calling something called login with HRF token.
And what is that?
That that is a function from a package called Huggingface hub.
And this is the first of those libraries I told you about.
This is the Hugging face library that's related to connecting to the Hugging Face Hub.
Okay, let's do it.
Let's run this.
And if all is well, if you've done the key properly, if you've copied and pasted, if it has the right
permissions and everything, you'll have a green tick there.
And this running on the cloud is now connected.
It's logged in to Huggingface.
So what I'm now going to do is run a piece of code that I'm not going to explain how it works, because
we'll be dealing with that another time.
It's using something called pipelines.
And we are going to be first.
We are going to be, uh, let's see what order do I want to do these in?
Yeah okay.
Okay.
So first of all, we are going to be using, uh, something that isn't going to be using a model, a
model from the Hugging Face library.
But it is not a transformer.
It is actually a different kind of model.
It is a diffusion model that you may have heard of.
It is a kind of model that's good at generating images.
And we're making one from a company called stability, uh, which is, uh, the, uh, the, the stability
diffusion model, and it's called Excel Turbo.
And we are going to ask it to generate a class of students learning AI engineering in a vibrant pop
art style.
So that is our prompt.
We are using something called pipelines that we will tackle.
We'll actually explain this tomorrow, but I'm doing it because this is now hitting our our T4.
So we should start to see work happening down here.
It says it's been executing for 22 seconds on the T4 and things are happening.
Whoa.
Look at all this.
Lots of status things.
So a lot of the time that you spend on Colab is actually spent downloading stuff, because the downside
of it being a completely clean box every time is that it doesn't cache any files you're downloading
things from the Hugging Face Hub every single time.
So all of this is downloading.
You can see here it says that's almost a 1.4GB of data coming there.
Uh, and uh, well that's, that's that's five gigabytes of data associated with this model.
And that's going to take a minute to download.
You can see the system memories coming up, but so far the GPU memory hasn't really moved at all.
Uh, and this is looking like we're filling a lot of CPU.
But fear not.
Once this thing is loaded, it's going to slam over to the GPU and we're going to run against the GPU.
Now hopefully you're doing this too because it's free, so why not?
So you are currently running this.
You press shift enter.
You are seeing the stability AI model running for a class of students learning AI engineering in a vibrant
pop art style.
All right, I'm gonna I'm gonna vanish for a second.
It'll be a few minutes for me.
It'll be a second for you.
And when I'm back, we'll see what comes of this.