Latest / Talk Python To Me / #318: Measuring your ML impact with CodeCarbon
Transcript
- 0:00Machine learning has made huge advancements in the past couple of years.
- 0:03We now have ML models helping doctors catch disease early.
- 0:06Google is using machine learning to suggest routes in their Maps app that will lessen the amount of gasoline used in a trip, and many more examples.
- 0:13But there's also a heavy cost for training these machine learning models.
- 0:17In this episode, you'll meet Victor Schmidt, Jonathan Wilson, and Boris Feld.
- 0:21They work on the Code Carbon project together.
- 0:24This project offers a Python package and dashboarding tool that will help you understand and minimize your ML model's environmental impact.
- 0:32This is Talk Python To Me, episode 318, recorded May 19th, 2021.
- 0:50Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 0:56This is your host, Michael Kennedy.
- 0:58Follow me on Twitter where I'm @mkennedy.
- 1:00And keep up with the show and listen to past episodes at talkpython.fm.
- 1:04And follow the show on Twitter via at Talk Python.
- 1:07This episode is brought to you by Square and us over at Talk Python Training.
- 1:12Please check out what we're offering during our segments.
- 1:14It really helps support the show.
- 1:16When you need to learn something new, whether it's foundational Python, advanced topics like async, or web apps and web APIs,
- 1:23be sure to check out our over 200 hours of courses at Talk Python.
- 1:27And if your company's considering how they'll get up to speed on Python, please recommend they give our content a look.
- 1:33Thanks.
- 1:34Boris, Victor, Jonathan, welcome to Talk Python To Me.
- 1:38Thanks for having us.
- 1:39Glad to be here.
- 1:40It's great to be here with you.
- 1:41Welcome, everyone.
- 1:42You all are doing really important work, and I'm super excited to talk to you about it.
- 1:45So we're going to talk about machine learning, how much carbon is being used for training machine learning models, and things like that.
- 1:54And some cool tools you built over at CodeCarbon.io and that collaboration you got going on there.
- 1:59But before we get into all those sides of the stories, let's just start with yours.
- 2:04Jonathan, you want to go first?
- 2:05How did you get into Python?
- 2:06Sure.
- 2:06Yeah, thanks for having us, Michael.
- 2:07My name is John Wilson.
- 2:08I'm an associate professor of environmental studies at Haverford College.
- 2:11I'm actually an environmental scientist.
- 2:13So I was brought in to kind of consult from the environmental side of this project.
- 2:17But I have a secret history as a computer science undergraduate back in the dark ages, learning to code on C, C++, and Java.
- 2:25And yeah, so I was brought in to kind of like provide that environmental perspective on the project.
- 2:30And, you know, having a little bit of a coding background, you know, despite how rusty it is, has been pretty helpful at thinking some of these connections through between computational issues and environmental issues.
- 2:41Yeah, I can imagine.
- 2:41Did you find Python to be pretty welcoming, given like a C background and stuff?
- 2:46Oh, gosh, yeah.
- 2:46I mean, you know, I learned back in the bad old days of, not bad old days, I shouldn't say that, scheme, things like that, you know, a little bit more challenging, you know, where it derives.
- 2:54Yeah, that's one of the first languages I had to learn for like a few CS classes I took.
- 2:58I was like, we're going to start with scheme, like anything with this.
- 3:01Give me something mainstream, please.
- 3:02Yeah, sometimes I feel like, you know, the sort of like older person, you know, telling the kids these days about how, you know, we had to walk uphill both ways in the snow to learn programming.
- 3:11And it's much, much easier.
- 3:12And it's one of the things I like about Python is it's really accessible to people from different fields.
- 3:17You know, you get into it from aspects of natural sciences, but even people who are like in the digital humanities are using it to, you know, for language processing and things like that.
- 3:25It's super flexible, which is really neat.
- 3:27Yeah, it's really impressive what people in those different fields are doing, how they can bring that in.
- 3:31Boris, how about yourself?
- 3:32How did you get into Python?
- 3:33I actually discovered Python during my master's degree.
- 3:36And I got a math teacher that introduced us to Python because they use Python for his own thesis.
- 3:43And I had one stuff to do, which was implementing RSA encryption.
- 3:47And I didn't want to do it because math was not my forte.
- 3:51So instead, I did some encryption inside images in Python.
- 3:55And I fell in love with Python.
- 3:57Oh, fantastic.
- 3:58Victor?
- 3:58I discovered this taking a data science class in, when was that?
- 4:042014, I think it was.
- 4:06That's really, I really entered Python through the data science perspective.
- 4:11And then I took a course in general web development.
- 4:15And we used Django.
- 4:16Oh, right.
- 4:16Nice.
- 4:17And so it's been, yeah, so it's been really like the main language I've been using.
- 4:21I was taught CS with Java and so on.
- 4:24So I was never a computer science fan.
- 4:28Like, I liked math.
- 4:30And I found Python to be really flexible in that regard.
- 4:33Like, you can do math super easily without, like, getting lost in translation.
- 4:36Yeah.
- 4:37One of the things that just came out is one of the new Texas instruments, the TI-84 calculator.
- 4:42They have a, you can now program it with Python.
- 4:44So that's kind of interesting now that it's one of the old calculators that everyone's probably used going through math and whatnot.
- 4:53Is now sort of, you know, more in the modern space.
- 4:56I think my first program was on my TI because I was bored in math course.
- 5:01And I cannot follow.
- 5:02So instead, I wrote some programs.
- 5:04Yeah.
- 5:04That's not a terrible way to spend your time.
- 5:07All right.
- 5:07So let's go ahead and talk about the main, you know, get to the main subject here.
- 5:12So let's start by just setting the stage.
- 5:15There's an interesting article here that came out.
- 5:18This is not even that new.
- 5:19It's, you know, 2019.
- 5:20And it's in the MIT Technology Review.
- 5:23So, you know, that gives it probably a little more than just some random blog says this.
- 5:28And it's got a picture, a big picture of a data center.
- 5:30And the title of the article by Karen Ho is,
- 5:34Training a Single AI Model Can Emit As Much Carbon As Five Cars Throughout Their Lifetime.
- 5:40So that sounds pretty horrible.
- 5:42But we also know that machine learning has a lot of value to society,
- 5:47a lot of important things that it can do.
- 5:48So here's where we are.
- 5:50And this seems like a good place to start the conversation for what you all are doing.
- 5:55I have a mixed feeling about this article.
- 5:57I think one of the great things it did is raise a lot of attention and awareness about this topic.
- 6:03I think a lot of approximations were made.
- 6:06And the goal here is not to criticize authors,
- 6:10but rather to say that in the meantime,
- 6:12things have evolved and our understanding has, I think, been a little more precise.
- 6:16Well, maybe because people are building tools that measure it instead of estimate.
- 6:20So there's that, definitely.
- 6:22And we hope that helps.
- 6:23But it's also one of the things you need to put in perspective is that the kind of model they're looking at is not necessarily your everyday model.
- 6:31Someone can just train on their local computer or even in academia.
- 6:36It's hard to get your hands on such large clusters and the number of GPUs used and so on.
- 6:43So like, I just want to put that in perspective that even if those numbers were accurate,
- 6:48and they are not, but I mean, it's a ballpark.
- 6:51It's not like every data scientist you'll meet and every AI researcher you'll meet is going to have something in that level of complexity that they train every day.
- 7:01Right.
- 7:02So I have over here a sim racing setup for some sim racing I do,
- 7:06and it has a GeForce 2070 in it.
- 7:10It would have to run a very long time to emit this much carbon, right?
- 7:14Like, you got to have the necessary money and compute resources to, you know, even get there, right?
- 7:21Yeah.
- 7:21Like the number, I don't remember exactly the setup that they're looking at in this paper,
- 7:26but like typically the modern language models that you hear about, like, oh,
- 7:32OpenAI has a new NLP model and like GPG-3, and it's that number of billion of parameters.
- 7:38Like, they train those things on hundreds and hundreds of machines for a very long time.
- 7:43This is not something you can do easily.
- 7:44It costs millions of dollars in investment upfront, and then just using those things is super expensive.
- 7:52So while I think we should be careful, it's not like the whole field is like that.
- 7:56Yeah, that's a very good point.
- 7:57I recall there was some cancer research that needed to answer some big problem,
- 8:02and there was an article where they spun up something like 6,000 virtual machines across AWS clusters for an hour
- 8:10and had it go crazy to answer, you know, some protein folding question or something like that.
- 8:15That would use a lot of energy, but it's extremely, extremely rare as well.
- 8:18On the other hand, you know, if you created that model and it solved cancer, well, you know,
- 8:23people drive cars all the time for less valuable reasons than, you know, curing cancer.
- 8:27Yeah, and I think just to build on what Victor said, you know, I think there was something really valuable about this article coming out.
- 8:32You know, I think for a long time, there's been attention that's been paid to the sort of environmental toll of supply chains in computing.
- 8:39You know, people have talked a lot about where minerals come from.
- 8:42Yeah, and one of the things that was really interesting about this article was, you know, with the approximations,
- 8:48it caught people thinking about the question that kind of animates our collaboration,
- 8:52which is when you're doing any kind of energy-intensive computational issue,
- 8:56you might want to think about where your electrons come from.
- 8:59You know, what's actually powering the hardware that you're using to do this?
- 9:04And I think this article did a really nice job of, like, focusing attention that there are some really energy-intensive projects
- 9:09that in particular ways, particularly if they're located in particular locations,
- 9:14they can have a really large environmental cost that isn't really transparent to the user or the person training the model.
- 9:20Yeah, yeah.
- 9:21Well, I don't want to go down this road just yet.
- 9:23I want to keep talking about the more high-level a little bit.
- 9:26But, you know, if the people who did this very expensive model,
- 9:29if they just said, I'm going to pick the closest AWS data center to me,
- 9:32that rather than, let me find the data center by just flipping a switch and say,
- 9:39no, no, maybe the one up in Prinnville, Oregon, by the dam,
- 9:43would be better than the one by the coal factory, for example, right?
- 9:47Like, that's something they could easily do, and it maybe doesn't change anything for them, right?
- 9:51Yeah, it's not always the case, because when you have, for example, health data and so on,
- 9:54there are legislations, but definitely, like, if you can,
- 9:58and there's more than just the money at stake here,
- 10:02and it's probably going to be a marginal change,
- 10:05because the prices tend to be not equal, but kind of uniform still.
- 10:09I think it's another decision item.
- 10:12Yeah.
- 10:12Boris, you got any thoughts on this article before we move on?
- 10:15Yeah, I think it came with a good, to highlight a serious issue,
- 10:21and if people want to improve it, as most of my manager told me,
- 10:26if you want to improve it, you must measure it before.
- 10:28So we are there to give us a start of an answer to, and give them action how to improve the cut carbon emission on training models.
- 10:39Hopefully to not train less models, but train better models.
- 10:44Yeah.
- 10:44I think, for example, this is part of what the recent Google paper, led by David Patterson,
- 10:50on training neural networks and their environmental impact.
- 10:54This is one of the things they say, and it's quite a dense paper,
- 10:58and a lot of metrics and so on.
- 11:00But one of the things they say is,
- 11:02if you don't want people caricaturing your numbers and putting approximations out there,
- 11:06well, you'd better publish those numbers yourself, right?
- 11:09And you need tools to do that.
- 11:11So if you're Google or if you're close to the infrastructure that you use, it's easier.
- 11:17It's even better if you have access to the plugs.
- 11:20But that's not the case of everyone, right?
- 11:22Right.
- 11:22So you're saying if you could put something to actually measure the electricity going through the wire,
- 11:27instead of some approximation, you're in a better place to know the answer.
- 11:30Yeah, definitely.
- 11:32That's where I think we might be a little ahead of your schedule,
- 11:36but we might go there still.
- 11:38Which is like, that's where Code Carbon comes into play, right?
- 11:41This is why we want to create this tool.
- 11:43This is a user-facing product, right?
- 11:46And I think it's very important to highlight that.
- 11:48It is not intended to be the solution for a data center.
- 11:53This is not something that we think should be deployed as a cloud provider,
- 11:58or if you own your own infrastructure,
- 12:01if you want to have centralized numbers, there are alternatives out there.
- 12:04Yeah.
- 12:04Things like scapandre.
- 12:06I don't know how you say that.
- 12:08It's a French word.
- 12:08Anyway, it's out there on GitHub.
- 12:10You can find it by just looking this way.
- 12:11But the goal here is, as a user, what can you do if you don't have those numbers?
- 12:15Do you do nothing, or do you try to at least have the start of an estimation,
- 12:22and maybe start the conversation with your organization or your provider?
- 12:26Yeah, fantastic.
- 12:27And you guys are putting some really concrete things out there for Python developers.
- 12:31Two quick high-level comments.
- 12:33One, Corey Adkins from the live stream says,
- 12:36would it be the same or worse for quantum computers?
- 12:39Okay, I'm going to talk out of my depth here.
- 12:41So the first, the best answer I can use, I don't know.
- 12:45And then to go beyond that, my understanding of quantum computers is that they do very different
- 12:51things.
- 12:51And you can't just compare the computations made on classical computers with the things
- 12:57quantum computers are intended for.
- 12:59I think intrinsically, because of the state of that technology, it is extremely energy intensive,
- 13:05just because you usually have to pull things down to a few millikelvins or something like that.
- 13:10So that may be transitory.
- 13:13I'm not sure.
- 13:14I don't know about that either.
- 13:15I was thinking the same thing.
- 13:16You know, just yesterday, Google had Google I.O.
- 13:19And they talked about building clusters of qubit sort of supercomputer type things.
- 13:25And apparently, they've got to cool it down so much that it's some of the coldest places in the
- 13:31universe inside those.
- 13:32So on one hand, if quantum computers can do the math super quick, it doesn't take a lot of time
- 13:37to run them to get the answer.
- 13:38But on the other, if you've got to keep them that cold, that can't be free.
- 13:41But it's a very particular kind of math, right?
- 13:44And not all problems are translatable from the classical formulation to a quantum compatible
- 13:51formulation.
- 13:52I'm not sure.
- 13:53I think there are problems that we can solve easily on our classical computers that would be
- 13:57very hard, if not theoretically impossible to run on quantum computers.
- 14:01And it's like, it's a different tool and it's not intended for the same problems.
- 14:06So I think it's hard to compare.
- 14:08Yeah.
- 14:08You will still have some parts of the model training that won't run on quantum computers
- 14:14because that doesn't make sense.
- 14:15Like pre-processing data, getting data from your different data source, mapping them to a
- 14:21common format, exporting your model, creating Docker images, servers.
- 14:25There will still be part of the model training process that won't run on those quantum computers.
- 14:33This portion of Talk Python To Me is brought to you by Square.
- 14:37Payment acceptance can be one of the most painful parts of building a web app for a business.
- 14:42When implementing checkout, you want it to be simple to build, secure, and slick to use.
- 14:47Square's new web payment SDK raises the bar in the payment acceptance developer experience and provides a best-in-class interface for merchants and buyers.
- 14:57With it, you can build a customized, branded payment experience and never miss a sale.
- 15:02Deliver a highly responsive payments flow across web and mobile that integrates with credit cards and debit cards,
- 15:08digital wallets like Apple Pay and Google, ACH bank payments, and even gift cards.
- 15:13For more complex transactions, follow-up actions by the customer can include completing a payment authentication step,
- 15:20filling in a credit line application form, or doing background risk checks on the buyer's device.
- 15:26And developers don't even need to know if the payment method requires validation.
- 15:29Square hides the complexity from the seller and guides the buyer through the necessary steps.
- 15:34Getting started with a new web payment SDK is easy.
- 15:37Simply include the web payment SDK JavaScript, flag an element on the page where you want the payment form to appear,
- 15:43and then attach hooks for your custom behavior.
- 15:45Learn more about integrating with Square's web payments SDK at talkpython.fm/square,
- 15:51or just click the link in your podcast player's show notes.
- 15:54That's talkpython.fm/square.
- 15:56Another thing I think it's worth pointing out is it's the training of the models that is expensive,
- 16:04but to use them to get an answer, it's pretty quick, right?
- 16:07That's pretty low cost.
- 16:09It depends on what you're using it for, right?
- 16:11So if you have a user-facing model that's going to serve thousands of requests per second,
- 16:16then deploying it for a year might be more energy intensive than training it for three days.
- 16:24We all know the machine learning lifecycle is not just like you train one model and you succeed and well,
- 16:28hooray, right?
- 16:30You usually have a lot of iterations, building the models, looking for hyperparameters and so on.
- 16:35But even if that takes six months and your model stays online for months or years and serving thousands of people,
- 16:42it's not obvious.
- 16:43It might even be worse, not worse, more energy intensive.
- 16:48Yeah, I guess it depends how many times you run it.
- 16:51Another thought, you know, there's a lot of places creating models, like you talked about,
- 16:55was it GP3, GPT-3, and whatnot, that are training the models and letting people use them.
- 17:01Do you see that as a thing that might be useful and helpful is having these pre-created, pre-trained models?
- 17:07Like I know Microsoft has a bunch of pre-trained models with their cognitive services,
- 17:11and Apple has their ML stuff like baked into their devices that you don't have to train, you can just use.
- 17:16Are the problems being solved and the data being understood usually too general,
- 17:20or is that something we can make use of?
- 17:22I think pre-trained models are the advantage to keep, as you are training a model once,
- 17:29the cost emission of the model during training is amortized for each usage.
- 17:35So the more user you have, the more part of the training emission is low.
- 17:40But usually you still have to tune the model a bit, so you still have to train it,
- 17:47and you're using energy even for prediction.
- 17:50So yes and no.
- 17:51I'm going to also do the transition to throw the ball to Jonathan for something I think we shouldn't forget
- 17:57when we talk about these gains in efficiency, which is like Jevon's paradox,
- 18:01and the fact that if you create something that is cheaper to use, and more people use it,
- 18:07then the overall impact is lower.
- 18:10And I think this is something we tend to forget when we talk about massive improvements,
- 18:15or not even massive, just like this is something that is, I think, hard to grasp and anticipate
- 18:21when you think about technological advances under the constraint of climate change.
- 18:25But this rebound effect is something we should plan for and not just think, well, if you have cheaper models,
- 18:32but more people can use them, I think it's not that obvious that it's an overall gain in terms of energy.
- 18:38Like then you can talk about all the societal consequences and the advances in cancer research.
- 18:44It's really hard to have a definitive answer.
- 18:46Yeah, just to build on what Victor said, it really is a difficult, I mean, this is a classic environmental conundrum, right?
- 18:52When, you know, the classic example of the Jevons paradox is, you know, adding more roads leads to more traffic
- 18:59because more people believe that there's more space for them to drive.
- 19:02And so you've seen this over and over again in all sorts of different contexts, that when you build these tools,
- 19:06more people will use them and that can end up costing more than not building them in the first place.
- 19:12So I think this is something to really be aware of, you know, as we're democratizing these kinds of tools.
- 19:16There's a real pro here.
- 19:18There are some real strengths of having these tools, you know, easily accessible and that can be used.
- 19:23But one has to worry about the potential costs of, you know, having all these tools being employed,
- 19:30in particular being employed in all sorts of different kind of sub-energy grids around the world.
- 19:34Not all grids are, you know, connected up to solar panels.
- 19:37You know, many are connected to coal-fired power plants and that can outweigh the cost.
- 19:42Yeah, we can hope, but it's not today, is it?
- 19:45Yeah, not yet, not yet.
- 19:46One would hope, but maybe soon.
- 19:48One last thought about pre-trained model is usually they are trained for more diverse usage.
- 19:54So I would think that they tend to be larger than model trained, especially for a single usage inside a single company with a single type of data.
- 20:04So I would say they are likely bigger, so they use more energy to train and to use, but by homage, I couldn't say.
- 20:11Yeah.
- 20:12Well, I think the paradox that you all are speaking about, you know, one of the ways we could see that is just the ability to use machine learning to solve problems is so much easier now.
- 20:21That what used to be a simple if-else runs in a microsecond is now a much more complicated part of your program.
- 20:28And so, yeah, there's got to be just a raising of the cost there.
- 20:32Now, before we make it all sound like machine learning bad for the environment, 100%, there are good things, you know.
- 20:39Google, like I said, Google I.O. was yesterday, and they were talking about doing the navigation so that taking into account things like topography, speed, and whatnot, to actually try to optimize, minimize gas consumption with the directions they give you, right?
- 20:56And if they could do that with a little bit of computer code to save a ton of CO2 out of cars, like that's a really big win.
- 21:04More ML.
- 21:04Definitely.
- 21:05And I think the reason why we're like, we have started with the online carbon emissions on our side at Mila in Montreal, and Jonathan and colleagues at Haverford with energy usage, and then we came together for quick carbon.
- 21:19It's not to say that machine learning is bad, like just as most technologies, it's technology, and it depends on how you use it.
- 21:27But where we're going as societies under the constraint of climate change can't leave any field out of questioning themselves of how they use their resources.
- 21:37So, yeah, it's something you can't leave out of the picture, which doesn't mean that you can't use it.
- 21:43It's like you have to think about it, and we can't have a single rule for everyone.
- 21:48It's just you have to take that into account, and you can very well make the decision that it is worth it.
- 21:53In many cases, it will be.
- 21:54Sometimes, maybe not.
- 21:55But be conscious of it.
- 21:56Yeah, for sure.
- 21:57All right.
- 21:58So, I think that brings us to your project, Code Carbon.
- 22:01You mentioned it a couple of times.
- 22:03So, looking in from the outside, it seems to me like the primary thing that what you guys have done is you've built some Python libraries, a Python package that lets you answer these questions and track these things, right?
- 22:16And then a dashboard and data that will help you improve it.
- 22:19Is that a good elevator pitch?
- 22:21Very good.
- 22:21Fantastic.
- 22:22All right.
- 22:23So, tell us about Code Carbon.
- 22:24Do you want to work for us?
- 22:25Yeah, sure.
- 22:26I'm not busy enough yet.
- 22:28We don't have any money, though.
- 22:29Oh, good.
- 22:30No, but I think it's a great cause.
- 22:31And so, tell everyone about it.
- 22:33Thank you for the opportunity.
- 22:34I think one of the reasons we came together was like, we all know that in the machine learning lifecycle, a lot of the computations you just forget about because there are so many experiments that you run.
- 22:46Like, say you have a project and you're going to work on it for like 3, 6, 12 months.
- 22:50How many experiments are you going to run?
- 22:52How many hyperparameter searches are you going to run?
- 22:54It's a very important problem.
- 22:57I think this is also something that is central to Comet.ml, which is the company where Boris works.
- 23:03They manage experiments.
- 23:05And I use that in my daily work.
- 23:09And I thought, well, we need something similar to track the carbon.
- 23:11It can't just be about the metrics.
- 23:14It can't just be about the images you generate because you're turning a GAN, for instance.
- 23:19So, how do we go about this?
- 23:21And, well, because Python was, I think, the go-to language for AI research and development also.
- 23:29Although, in very optimized settings, you might want to go away from that.
- 23:32But we thought, well, we need to do something that is going to be plug and play.
- 23:36So, it has to be Python.
- 23:37It has to run in the background.
- 23:39It has to be light.
- 23:41And it has to be also something that is versatile in that it is not only about you're just getting yet another metric, but it's also about understanding what it means.
- 23:52It's about also education.
- 23:55It's about education for yourself, but also maybe for other members of your organization.
- 23:59The people who might say, like, say you work in a company and you're thinking, well, I have hundreds of data scientists.
- 24:06Like, this is not marginal.
- 24:07I want to have an estimation.
- 24:09And if estimation is not good enough for you, well, contact your provider and maybe have a wattmeter plugged in somewhere where it matters.
- 24:16It's not my expertise.
- 24:17But that's basically the idea.
- 24:19Yeah, yeah.
- 24:19Well, I think plugging in a wattmeter somewhere, that used to be a thing that you could do.
- 24:24But now it's Amazon or Azure or Linode or whoever.
- 24:29They're not going to let you go plug it into their data center.
- 24:33And if you did, there's probably a bunch of other things happening there, right?
- 24:35Direct access to the compute resources is just hard to come by.
- 24:39Yeah, exactly.
- 24:40This is a very big constraint for us.
- 24:42I think I expect we'll get into a little more details about that.
- 24:45But this is why you need to understand carbon as a tool to estimate things and have approximations.
- 24:50And we use heuristics.
- 24:52And basically, if a consultant is having you pay for carbon offsets based on those kinds of numbers, you shouldn't pay.
- 24:59Because that's not the point.
- 25:00Yeah, it's really about giving you the information.
- 25:02One of the things I like about what you're doing is you can recommend other areas.
- 25:07Like we talked about, like you could switch to this data center.
- 25:09And then it would have this impact, right?
- 25:11Yeah, I think it's part of the educational mission.
- 25:13It's like we all know, or at least I wish we all knew or we want everyone to know.
- 25:18I don't know how to put that.
- 25:19But that it's the climate change is a very serious threat.
- 25:23And being conscious about your energy usage and your consumption of resources in general is one thing.
- 25:32It's very important.
- 25:32But then I think you consciously leave people out there with that feeling of guilt.
- 25:36And there has to be actionable items.
- 25:39Changing your region is probably the easiest thing you can do, especially in the age of the cloud.
- 25:44And at a time when basically moving your data across continents is about picking a few checkboxes on a web interface.
- 25:54Yeah.
- 25:54I think just to pick up a little bit on what Vic Victor has said here is that the educational part of this is a very important part of the Code Carbon project.
- 26:01Because we know as we have been involved in this, that answering this question, like what's the CO2 footprint of my computational work, is actually a very, very difficult question to answer.
- 26:11And it's opaque for a variety of reasons.
- 26:14It's opaque because the way that the energy industry deals with CO2 emissions is pretty opaque, unless you know the language of how they express this.
- 26:23And it's also difficult to understand when you are able to make the calculation, what does that mean?
- 26:29What's one gram of CO2 emitted relative to, say, everyday activities?
- 26:34So one of the things that we've tried to do as part of this dashboard is simplify those two steps for people.
- 26:39Because we've been approached by people via email, via Slack, and we know we're not the only people concerned about this.
- 26:45And so this is just a way to help make these approximations both visible, but also kind of comprehensible and put it in the context of human activities.
- 26:56You're right.
- 26:56There's a lot of layers and, you know, companies that run the clouds, they are trying to be more responsible with their energy.
- 27:03But you don't know.
- 27:04A lot of times you don't know if this data center, US, East, one, and AWS, how much energy from different sources is that actually using?
- 27:14How much have they actually built their own solar and wind?
- 27:18We don't know, right?
- 27:19But you get a better sense using your tool.
- 27:21You've got better data than the random person who just kind of estimates, well, they're doing some stuff, so it must be fine.
- 27:27Another important thing I think is, and Jonathan is much more an expert in that than I am, but not emitting is very different from offsetting in whatever way, wrecks or whatever.
- 27:39Yeah.
- 27:40Your emissions and our atmosphere, our climate has inertia.
- 27:44And the expected compensation in 5, 10, 20 years of your current emissions.
- 27:51Those are two very different things, right?
- 27:54And it's much easier to put carbon in the atmosphere than taking it away from it.
- 28:00And so I think it's not just because you read Google and others, Microsoft are carbon neutral, which comes from compensations of many forms.
- 28:10It doesn't mean no carbon was emitted, right?
- 28:13Yeah, there's just to build on Victor's point again, you know, there's decades of research in sort of what you'd call, you know, environmental psychology, explaining to people the consequences of inaction or, you know, of diffuse environmental costs to a particular action causes long-term behavior change.
- 28:29And I think, you know, one of the things that's been really exciting about seeing the, you know, the machine learning and AI communities kind of like grapple with this question in a very public way is we've started to see articles of, you know, pressure being put on organizations to why don't we have more green energy infrastructure, you know, undergirding our work.
- 28:48And so, you know, the speed at which this has become, you know, a public conversation is really heartening, you know, as somebody who's been working in the environment for quite a bit of time.
- 28:59Yeah, I would say it does seem to be getting a lot of attention, which is good.
- 29:02It's a big problem.
- 29:03But attention instead of just head in the sand is a really big deal.
- 29:06Like we've been driving cars for a long time.
- 29:08We've been flying planes for a long time.
- 29:10There's a lot of like raised trucks with super big wheels with, you know, dual coal stack pipes on them, right?
- 29:17Like that's, I can't speak for everyone that gets a truck like that.
- 29:20But I feel there's a lot of times when we have these conversations, people are just like, well, this is so horrible and so vague that I'm just going to live my life and enjoy it.
- 29:29Because I seem to not be able to do anything anyway.
- 29:31So I might as well have fun instead of not have fun while things are going wrong, right?
- 29:36Like that's kind of that psychology, right?
- 29:37And so I don't know.
- 29:38How do you all deal with that?
- 29:39It's also something that like when it's not before your eyes, it's much more difficult to answer, to understand and to respond to.
- 29:47And I think this is part of what we're seeing today with decades of activism is like facts, hard facts are not enough to convince humans.
- 30:00And then to some extent, it's also a good thing.
- 30:02And it has, I think, value in our recognition.
- 30:06But it also has this downside that it's just because you say a number to someone, if they don't understand it, if they don't see it for themselves in their everyday life, it's going to be very hard to understand.
- 30:18So until you have used something like Code Carbon, like I code every day, I train models every day, and I train a model for five days on a GPU in Quebec.
- 30:29That's my daily life, basically.
- 30:31And some might find it dull.
- 30:33I like it.
- 30:34Anyway, that's not the point.
- 30:36I mean, until you have that and you're like, oh, this is what I do.
- 30:39Those numbers start to make sense.
- 30:41Even if you have numbers for your day to day, that doesn't seem that much, like thousands of grams or kilograms.
- 30:48But once you sum all the emissions for all the model trained, for all the machine learning teams, for all the machine learning data scientists, for a company for a year or even for academia, that start to get, depending on your size of the company, of course, that start to get sizable.
- 31:06And you might want to take a serious look at it.
- 31:09Yeah.
- 31:09I want to dive into the code and talk about this.
- 31:13But I guess maybe speak really quickly to, I work at a company.
- 31:17We make shoes.
- 31:18They want me to use ML to figure out how to get better behaviors out of the materials for track runners or whatever.
- 31:26So I do that.
- 31:26That company, how do I get that company to say, yes, we should measure our scientific data science work and we should offset it?
- 31:35There's a lot of layers between the people who care about shoes and sales and people who care about machine learning carbon offsets.
- 31:43My personal understanding of this situation is that empowering individuals with tools and numbers to convince organizations is part of our mission.
- 31:53So if what the person in charge, whatever their role in the organization, thinks that in order to have an estimation of their carbon impact, they have to find a consulting firm, pay people for five weeks.
- 32:08If they think this is the process, they're going to be reluctant.
- 32:11And I can understand why.
- 32:14If you have a plug and play tool that even you as the evangelizer, if that's a word, you get the idea.
- 32:22Yeah.
- 32:23It doesn't cost you much to try.
- 32:24The way we want to build this thing is just like one import and full of lines.
- 32:29Yeah.
- 32:29So, yeah.
- 32:30So let's talk about the code.
- 32:31I think maybe the answer, maybe an approach that you could have there is we'll run something like this on all of the training that we do.
- 32:38And then we're going to report up our division in this company generates as much carbon.
- 32:43So if you care about carbon, you need to take that into account.
- 32:45I think that's a good selling point.
- 32:47I think as we can see today together, I mean, those conversations are hard and long and it's not easy to understand all that matters.
- 32:56And you may need that consulting firm in the end to help you understand what's at stake in your whole value chain.
- 33:02You got to start somewhere.
- 33:04Right.
- 33:04And if you're an individual and you want to change your organization, well, I think if you want to have an impact, those kinds of tools should be easy to start with.
- 33:13And then, as we've said, it's not enough and it's not precise enough.
- 33:16And then there are other steps you can take.
- 33:18But you need to get the conversations going and started.
- 33:22Yeah.
- 33:22And to start that, you got to start measuring.
- 33:24So in order to do that, let's talk about the code.
- 33:26It's literally four lines of code.
- 33:28It's all you got to do.
- 33:29So you pip install Code Carbon and then from Code Carbon, import Emissions Tracker.
- 33:34Create one.
- 33:35Tracker.start.
- 33:36Do your training.
- 33:36Tracker.stop.
- 33:37And that's it, right?
- 33:38Right.
- 33:39And with the decorator solution, it's seven, two lines of code.
- 33:42Yeah.
- 33:44With the decorator, you can just put a decorator on a function.
- 33:46And then basically any training that happens during that will be measured and then saved to a CSV file.
- 33:53Right?
- 33:53That's correct.
- 33:54And if you think a context manager should be implemented, well, you're welcome to create a PR.
- 33:59It's going to be super easy.
- 34:00Everything is already there.
- 34:01Yeah, exactly.
- 34:02I can already see it in my mind with Emissions Tracker, you know, as Tracker.
- 34:07So it creates one of these CSV files and then what?
- 34:10So there are a bunch of things that happen.
- 34:12If you want to, like, the two big steps are, one, you look for the hardware you understand,
- 34:19like Code Carbon understands, then you track those, you measure the energy consumed, right?
- 34:26And so you have that, basically, you measure the energy.
- 34:29And then next step is, well, how much carbon does energy has emitted?
- 34:35How does energy emitted?
- 34:36And so you need to map the code to your location.
- 34:39Right.
- 34:39And do you do that by just, like, a get location from IP address type of thing or something like that?
- 34:45So you can either do that or provide the country ISO code for a couple of countries, Canada, the US.
- 34:53We have regions below the national level.
- 34:55Another thing that you can actually do is, well, it's not going to help you with the location,
- 34:59but it's going to help you with the carbon impact is we can bring CO2 signal,
- 35:05which is an API that is being developed, the electricity map, initiative, group, organization, company,
- 35:12whatever their status.
- 35:13And so that's going to help you an exact estimation at that moment in time,
- 35:17depending on what data you have of those computations.
- 35:20Otherwise, we need your country code and we're going to map that to historical data.
- 35:24This CO2 signal, this is new to me.
- 35:26What is this?
- 35:26I think you'd better look at them.
- 35:28Exactly.
- 35:29The electricity map.
- 35:31Look at the map.
- 35:31Exactly.
- 35:32Yeah.
- 35:32So they have products, they have predictions of carbon emissions and so on.
- 35:38But that's basically, it's an initiative.
- 35:40The organization is called Tomorrow.
- 35:42The goal here, at least with the electricity map, is to gather data about carbon intensity
- 35:48and the energy mix of countries through the forest of APIs and standards countries have for countries and companies and have for that kind of thing.
- 36:00So you can see that in Canada, not all or in the US, not all regions are going to work similarly.
- 36:07And some regions might not even provide that kind of data in the open.
- 36:11Yeah, that's too bad.
- 36:12Yeah, but it's really different depending on where you are and just even the US, right?
- 36:18Like in the Pacific Northwest, I think it's like very high levels of hydro.
- 36:22Southeast, a lot of coal still.
- 36:25Like it's not just what country.
- 36:27It's even like maybe a little more granular than that, right?
- 36:29No.
- 36:30At least for large places.
- 36:31And also, as you can see, I think this is also a very interesting map because you can see that energy grids are very different from the grid that you know, like nation, state, whatever it is after that, right?
- 36:44Yeah, county, city.
- 36:45County, city, all of that.
- 36:46Like you can see, for example, the one that spans something like Iowa.
- 36:50Italy, for example.
- 36:51I was thinking, it already are like this thing that goes from Montana to Texas or something.
- 36:56Yeah, that doesn't look like any state I learned in school.
- 36:59No, but it's probably it's unified grid for some reason because providers got together for under some constraint.
- 37:05Yeah, exactly.
- 37:06So when I'm looking at this code here, I run that and then I get this map and it can give you recommendations on the cloud regions, right?
- 37:14And where you might go.
- 37:15So for example, CA Central 1.
- 37:18This is something that we might want to change, right?
- 37:20The UI of this thing might not be obvious, but you're on the left.
- 37:23This, I just want to specify clarification because I even, I sometimes forget.
- 37:29I'm like, where did this, where was this thing run?
- 37:32That's actually, yeah.
- 37:33You run on the left and we show you how it could have been different.
- 37:36Interesting.
- 37:36Somewhere out.
- 37:37Yeah.
- 37:37So if I pick say US West 1 for AWS versus EU West 3, you can see the relative carbon offset or production.
- 37:46Yes.
- 37:46How bad that was or how good it was.
- 37:48And these are all comes from those reports generated out of that CSV file.
- 37:52Exactly.
- 37:52That's correct.
- 37:53I just want to be clear about how the data was gathered.
- 37:55That's a very important topic.
- 37:58So we still need to update the data for GCP, Google Cloud Platform, because they recently released those numbers.
- 38:06But for most of those locations, we had to make an assumption.
- 38:10The assumption was that the data center was plugged to the local grid.
- 38:15So if a data center is in Boston, we assume the data center uses the same energy as Boston's grid, which might not be the case.
- 38:24Right.
- 38:24Many providers would not now have their own solar panels and whatnot.
- 38:30So that might not be the case.
- 38:31And so, but unless they release those numbers and I can find the link, I'll share it with you.
- 38:37Unless we have those numbers publicized by the providers, I mean, there's only so much we can do.
- 38:42Yeah.
- 38:42So, yeah.
- 38:43Well, here's a call to action for those who haven't released it.
- 38:46Get on it, right?
- 38:47I think it was part of Jonathan's message earlier, which is like, there are so many layers and so many of them are opaque.
- 38:54That's part of the, I think, our responsibility as users.
- 38:58Yeah.
- 38:59I don't like to put too much weight on individuals' shoulders.
- 39:01And I think structural changes have a much wider, well, much more potential.
- 39:06But I think it's still interconnected.
- 39:09And if you can do something about it, well, you should.
- 39:11Yeah.
- 39:12Let's talk a little bit about running it.
- 39:14So when I go over here and I say start and then stop, like, how do you know how much energy I've used?
- 39:20I mean, I know once it leaves the computer, like, there's a lot of assumptions and various things like we talked about.
- 39:26But how do you estimate how much that that code has taken?
- 39:29That's a very good question.
- 39:31And Victor, can I answer this one?
- 39:33Oh, yes.
- 39:33Sure.
- 39:34Okay.
- 39:35When you're training and you're running a machine learning program, you are mostly using GPU.
- 39:41And you are mostly using NVIDIA GPU.
- 39:43And thankfully, NVIDIA has a nice SDK to get, at a given time, the current estimated plus or minus 5% energy usage of the GPU.
- 39:55So we get...
- 39:56Oh, really?
- 39:57Okay.
- 39:57So it's not like you're saying, oh, it's a 3070 super and it must be pinned CPU-wise or GPU-wise.
- 40:04So let's just assume this much time times this kind of computer, it gives you more narrow, exact measurements.
- 40:11Okay.
- 40:11Fantastic.
- 40:12We still get the energy consumption from all GPU.
- 40:16So if you are training multiple models, we might get higher or lower energy estimation.
- 40:22I'm not sure there.
- 40:22So that's for GPU.
- 40:24For CPU, we are supporting Intel.
- 40:27And we have several ways of doing that as we get a measurement at the beginning of the training and at the end.
- 40:34And we get the total energy usage between the two.
- 40:37So we can get the difference.
- 40:38Or we can also regularly get the immediate usage, I think.
- 40:43We are working to add memory usage because even if GPU and CPU are the topmost resources that you use for multi-gigabytes,
- 40:54it tends to be not negligible.
- 40:57And once you get...
- 40:58Probably disk as well.
- 41:00Yeah.
- 41:00Everything takes energy.
- 41:01The goal is to focus on what takes most of the energy and how easy it is to get that consumption.
- 41:09So you get all of that either during the training frequently or at the beginning and the end.
- 41:15In addition, we get the duration.
- 41:17And we detect if you are running in a data center or not.
- 41:22So in case we don't have access to anything, like you are running on AMD GPU, on an AMD CPU, on Windows,
- 41:33we can still give you an estimation based on the duration, on your estimated location.
- 41:39Or if you are running inside a data center or a specific location, we can also get a more precise estimation for you.
- 41:46And we are measuring what energy usage.
- 41:49And then we can use our data to estimate again, like estimation of estimation, the CO2 emitted for that usage.
- 41:58I don't know how deep you want to go into how it works, but I do want to point out that...
- 42:04Give us a little look inside.
- 42:05Yeah.
- 42:05Yeah.
- 42:06Given that it's one of the most difficult areas, I think I also want to use your platform to call for help, which is...
- 42:12It's actually the low-level inner workings of CPUs are hard to understand.
- 42:18At least for me, I have a background and I'm a researcher, right?
- 42:22So it's an area where we need help.
- 42:25Not necessarily a hardware specialist, right?
- 42:27And writing on hardware, yeah.
- 42:29Exactly.
- 42:29And so, for example, the way we read the energy consumption of Intel CPUs, I mean, the GPUs, as Boris said, have, at least NVIDIA's GPUs, have this driver that we can ping.
- 42:43And NVIDIA SMI is all the INVML package is very useful because we can just ping this and not care about how it's done and trust NVIDIA and use that number.
- 42:54But for the CPUs, it's much more complicated.
- 42:57The reason is that what happens under the hood is modern Intel CPUs under the right settings write, actually, their energy usage, millijoules to a textile.
- 43:09It's the Rappel interface and they write to a textile the number of millijoules they have consumed since, I don't know when, since they were turned on or the 1st of January 1970 or whatever other random date.
- 43:23Yeah.
- 43:23What matters is that and we look at the difference in it.
- 43:26But those numbers are written by the CPU socket.
- 43:30So let me give you an example.
- 43:32In the academic setting where I work, we have shared clusters.
- 43:37I can request part of a node and I'm going to request one GPU and 20 CPUs to do my computations.
- 43:45But what I saw looking at the Rappel files is that there are two sockets of 40 CPUs.
- 43:53Like we have 80 CPUs per node and two sockets of 40.
- 43:56So there's no way to read from the Rappel files.
- 43:59Your granularity is 40.
- 44:00Yeah.
- 44:00Yeah.
- 44:01Like the CPUs that are allocated to me might change over time.
- 44:04Maybe not.
- 44:05It depends on the resource manager.
- 44:07You use Slurm and those CPUs will be split across those two sockets.
- 44:12And so we have that level of problems too.
- 44:16So the high level, you're working in a dedicated environment and it's only your program, then
- 44:22Rappel is perfect and we couldn't have dreamt for something better.
- 44:25But it does not allow us to go to the core, let alone the process granularity of power consumption.
- 44:33So I just want to put a big warning here.
- 44:37And one of the things that we need to look into, and it's very hard and there are no good numbers.
- 44:43Maybe even what I'm going to say won't make sense.
- 44:46But the only solution we have left is, is there some kind of heuristic to map the CPU utilization
- 44:54to the energy consumption, basically.
- 44:57Because otherwise, we're never going to be able to attribute your processes and sub-processes'
- 45:04CPU usage to WAPs, basically.
- 45:07Because of this Rappel setup that is written by a socket.
- 45:11And I've talked a little to people who understand this way better than I do.
- 45:17And they thought this endeavor was very risky.
- 45:20And they were pessimistic.
- 45:22But I mean...
- 45:23And you're like, what else do we have to work with?
- 45:25Yeah.
- 45:25And so I think next thing is like, we're going to need to get our hands on hardware, have
- 45:31it run and see how bad it is.
- 45:32And it's going to be one setup with one mode for the compilation of the math libraries I'm
- 45:40going to use to benchmark and whatnot.
- 45:41Like, there's only so much we can do if the hardware providers don't give, don't tell
- 45:46us more.
- 45:46It would be nice to see operating systems and then the hardware providers as well allow
- 45:53you to access that information, right?
- 45:54Like, how much, you know, how much voltage am I, how much am I currently consuming with
- 46:00just this process, right?
- 46:01And you don't want to profile it.
- 46:02Because if you profile it, you'll be like 50% of the problem, right?
- 46:06And you'll slow it down and people won't want to touch it.
- 46:08And talk to people at Power API and Pyjool initiatives.
- 46:13And even they, from what I remember, explained that even if you had total control on the hardware,
- 46:21on the software, or the hardware, both of those things are going to be so dependent on the way
- 46:26you compile the libraries you use.
- 46:28And a number of other facts that it's even the very definition of those things that we're
- 46:35looking for is not obvious.
- 46:36Or whether it's Linux versus macOS versus Windows, it's got to make a difference.
- 46:40It all matters.
- 46:41And the reason why I think it's still worth looking for an approximation through CPU utilization,
- 46:48even if it's a bad proxy, is it's all bad proxies.
- 46:52So why is it like, it doesn't matter if you're precise to the millijoule on your CPU,
- 46:59if your uncertainty around carbon emissions is huge, right?
- 47:04Otherwise, you end up with something as much carbon as five cars, right?
- 47:07And so...
- 47:09We can get it down to 2.1 or 2.2 cars.
- 47:11Come on, let's go with that.
- 47:12Yeah.
- 47:12So it's really a very complex endeavor.
- 47:15Yeah.
- 47:16Yeah, absolutely.
- 47:17So it sounds like it runs on multiple platforms.
- 47:19We'll try to, at least.
- 47:21Yeah, yeah.
- 47:22So Windows, Linux, macOS.
- 47:24Exactly.
- 47:25I'm sitting here recording on my Mac Mini M1, Apple Silicon.
- 47:29Can I run it here?
- 47:30Yeah.
- 47:30You would need to install the Intel Power Gadget, restart your computer, allow specific security
- 47:37permissions.
- 47:37Not an Intel CPU.
- 47:38So I'm guessing you will be back to the simple realistic base on the duration.
- 47:43We realized, actually, the Intel Power Gadget also tracks some AMD CPUs.
- 47:47Like, we had a user say, like, you don't seem to support AMD.
- 47:51And then they still installed the Intel Power Gadget.
- 47:53I don't know why, but they did.
- 47:54And then it worked.
- 47:55So I'm like, I'm not sure how this thing works.
- 47:58So Intel AMD, but maybe not Apple Silicon.
- 48:00I don't think so.
- 48:01Okay.
- 48:02Well, probably most people won't be doing training on that.
- 48:05The Apple Silicon platform has a dedicated course for machine learning, you know?
- 48:09It does have, I think, 16 ML cores.
- 48:11Yeah.
- 48:11So yeah, maybe.
- 48:12Maybe they are.
- 48:13They're coming out with the Mac Pro, which is supposed to have Mini Mini 4.
- 48:17So maybe that'll be where people do it more.
- 48:20So if Apple is hearing you.
- 48:21Yeah, pretty.
- 48:22Is hearing us.
- 48:23Send us a Mac Mini and we'll work on improving the tracking of.
- 48:28And one Mac Mini is for all three of you.
- 48:30The whole team.
- 48:30Come on.
- 48:31Let's send it along.
- 48:32Make it happen.
- 48:32You have my Twitter handle.
- 48:33Send me a message.
- 48:34Fantastic.
- 48:35All right.
- 48:35Let's see.
- 48:36Before we move on, quick question from Brian in the live stream.
- 48:39Other than moving to different data centers, what are some of the highest impact
- 48:42changes people can make?
- 48:44Different training methods and so on.
- 48:46And by the way, that also leads exactly into where I was going.
- 48:49Thank you for that.
- 48:50A very timely question.
- 48:51Like patterns and things you can do.
- 48:53Let's talk about that.
- 48:54One of the things that we wrote in the carbon emissions of machine learning paper on the
- 49:00website is, well, there's hyperparameter searches.
- 49:02Like one of the worst thing you can do, both in terms of pure ML performance and carbon emissions
- 49:09is grid search, for instance.
- 49:10So maybe just don't do that.
- 49:12There are, if you're lazy, just do a random hyperparameter search.
- 49:16Or if you don't have a good metric.
- 49:18Or use Bayesian optimizers and so on to look for those hyperparameters.
- 49:22Another thing that is not mentioned in that paper, but I think is still very important.
- 49:27And that cycles back to one of your first questions about insurance versus training is,
- 49:32there are many methods out there.
- 49:33Pruning, distillation, quantization, all of like all that zoo of tools and techniques
- 49:41and algorithms to optimize your model.
- 49:45And if you're happy with your current model, chances are there are many techniques out there
- 49:50that can reduce its size and computational complexity by multiple factors.
- 49:56So if you're going to put a product out there with hundreds, thousands, millions,
- 50:02of inferences, maybe just think about that.
- 50:05I expect people who deploy such tools do think about that.
- 50:09If you're deploying a tool for millions, I mean, it's in your interest to think about it
- 50:14because it's also going to be cheaper.
- 50:15They probably think more about it in terms of just time, time to train, time to get an answer.
- 50:22But that also is exactly lining up with energy consumed.
- 50:25So, you know, CO2 reduction comes along for the ride.
- 50:29Yeah.
- 50:29It's often the case that if you invest in ecological solutions, they are going to end up being economical.
- 50:34Jonathan, it's more of your area.
- 50:38Maybe that's another bold pro to you.
- 50:41Oh, I couldn't underscore that more.
- 50:43I think, you know, something that I think that has come out of our results that we've seen is that
- 50:47there's not a strictly linear trade-off between energy usage and accuracy, for example.
- 50:53There's often, there's a shoulder usually there and finding that shoulder using code carbon to figure
- 50:58out, you know, if I throw this fraction of a kilogram of CO2 at this problem, I'm actually
- 51:03going to get a lower accuracy than if I had stopped beforehand.
- 51:06So using a tool to figure out where that is, I think is very helpful.
- 51:10And so just being aware of the impact of it and trying to maximize for accuracy and not just energy usage.
- 51:17Yeah.
- 51:17One of the things you called out is more energy, which means more emissions, is not necessarily
- 51:22more accuracy.
- 51:22Yeah.
- 51:23Adding on more practical solution.
- 51:24For example, when you're doing hyperparameter search, which is basically, are you doing the
- 51:30combination of numbers of variables and try to find the best combination to get the best results,
- 51:36the best, more precise model or whatever metrics you're optimizing for?
- 51:41You will likely, most of the machine learning libraries have an option to do early stop.
- 51:45Like instead of doing training new model for four days for all hundreds of thousands of combinations,
- 51:53you train 10 of them for one day and then you see how it evolved.
- 51:59And if you take only the two best of them and try again, you can reduce your training time
- 52:05and emission by a lot of percentage.
- 52:08And on other protocol, you can also move all known, all the code that doesn't need GPU to
- 52:15run something somewhere else, like for CPU, then you start on disk, it's still emitting less
- 52:20emission than not using the GPU on your server.
- 52:24And try to use your GPU better, even by training more model on the same GPU or changing your model
- 52:31to be more efficient to train in less time.
- 52:35One of the things that we've also advocated for, and it can sound a little naive, but as
- 52:39Jonathan said earlier, like this field has been moving fast is to publish and be transparent
- 52:45about those things.
- 52:46And I think if the community shows interest and shows that it is one of the broader impact
- 52:53features that they look for when they think about the systems they create and deploy, I
- 52:59think it's also something that can spread in other areas than just your very specific niche
- 53:04of research.
- 53:05For instance, I'm thinking about the research community here, but that's my environment.
- 53:10But I think it's also the case in the industry.
- 53:13Another thing that you all talked about is if you're computing locally, so maybe at your
- 53:18university or in your house these days, that's probably where you are.
- 53:21The local energy infrastructure matters, right?
- 53:23It does.
- 53:24It does.
- 53:25Like, for example, Quebec has an average of like 20 grams of CO2 per kilowatt hour or something,
- 53:32which is probably 40 times lower than some other regions.
- 53:36You can check the, well, no, because Quebec doesn't share the data with electricity map.
- 53:41It's a shame.
- 53:41But you can see other, like if you just compare the results in Europe, for instance, and you
- 53:47look for France, which is...
- 53:48Like France versus Germany.
- 53:50Yeah.
- 53:51It has a nuclear electricity grid, mostly France, right?
- 53:54So if you compare France to Germany, it's going to be very different.
- 53:58Look at that.
- 53:5895% low carbon.
- 54:00That's well done, France.
- 54:02Good job, Boris.
- 54:03I think if you click on Germany, what you'll see is you might have a time series somewhere
- 54:09for the last 24 hours.
- 54:10At least have this nice breakdown over here and you can move it.
- 54:13Yeah, there's your time series.
- 54:15Right.
- 54:15So you can even see that during the day.
- 54:18It's not the same.
- 54:19And just like your electricity provider will charge you differently for different times of
- 54:25usage, like high demand or lower demand times of the day.
- 54:29And like carbon emissions are also going to have that kind of variation that you could
- 54:33care for.
- 54:34One thing I wanted to give a quick shout out to, I don't know about different locations.
- 54:39Here in Portland, one of the options we have is to choose a slightly different energy choice.
- 54:45If we pay $6 more per month or $11 as a small business, it will basically be wind and solar.
- 54:52And if your local grid offers something where you literally pay $6 and it can dramatically
- 54:57change it, like, you know, do the world a favor.
- 54:59Opt in.
- 55:00We have the equivalent in France also.
- 55:02Same in the United States.
- 55:03There's a lot of, there's a patchwork of different state laws that mandate that these options are
- 55:07made available to people.
- 55:09So yeah, definitely take advantage of it.
- 55:11Yeah.
- 55:11Yeah.
- 55:12It's, I mean, it literally is a checkbox.
- 55:13Do you want to have this yes or no and a small fee?
- 55:16And they probably, you know, honestly, probably what's happening when you check that box,
- 55:19like some of that energy would have just gone to the general grid and now it's, it's promised
- 55:23to you.
- 55:23But soon as enough people check that box to go beyond the capacity, then that's going to
- 55:27be an economic driver to make more of it happen.
- 55:30Right.
- 55:30So hopefully, hopefully we can get there.
- 55:33Although I suspect data centers are where the majority of the computation happens.
- 55:37It doesn't, I mean, I'm not backing this by any knowledge here.
- 55:41I'm just, it's just my personal perception, but I feel it's like, it's too little.
- 55:46Like, this is too cheap.
- 55:47How come, like, it's so cheap, right?
- 55:51So, so many things in our data lab should actually be more expensive if we knew how much energy
- 55:57and resources and how much they cost the environment.
- 55:59And so it feels like it's a no brainer when it's so easy and it's so cheap in this case,
- 56:04but like how many other areas of our data lab and consumption have those, those biases?
- 56:10Would you pay three times as much to fly, right?
- 56:13Would you pay $3,000 to go from France to Portland rather than a thousand or whatever, right?
- 56:17That's a harder thing than checking a $6 box.
- 56:19Yeah.
- 56:20And probably a harder solve a problem.
- 56:22But luckily we're, we're talking about computers and ML and not air transportation.
- 56:26So don't have to solve it here.
- 56:28We'll do that next time.
- 56:29Speaking of solving it here, you know, what's next?
- 56:30Where are things going for you all in the future?
- 56:32So I'm a PhD student at Mila in Montreal.
- 56:35So it's a Quebec's AI Institute.
- 56:38So I feel like I'm going to stay there for at least two or three more years until I PhD
- 56:43and then we'll see.
- 56:44But the other two, where are you going with this project?
- 56:46Yeah, I think that we've got some things on the horizon.
- 56:49One is that the other part sort of under the hood that's kind of complicated is deriving
- 56:54the energy mix and getting the CO2 intensity of the energy grid from the energy mix.
- 56:58So figuring out, you know, okay, if you know, you have X percent natural gas, X percent coal
- 57:03and X percent oil, you know, how does that translate into CO2 emissions?
- 57:06That's actually an extremely complicated problem to answer because we have different chemical
- 57:12compositions of coal around the world.
- 57:14For example, you know, coal that comes out of Kentucky has a different CO2 impact per,
- 57:19you know, joule from combustion than coal that comes out of Wyoming, for example.
- 57:22So we've got all these different layers to figure out.
- 57:25For oil, you've got like the oil sands of Canada versus...
- 57:28Exactly.
- 57:28...Sahary Arabia or whatever, right?
- 57:30Exactly.
- 57:30Yeah.
- 57:31And all of these sort of chemical differences, you know, matter and they reflect different
- 57:35efficiencies.
- 57:36And that's not even getting into the difference in hardware in different power plants.
- 57:40So what we want to do is we want to actually dive in a bit deeper and get at some of these
- 57:45regional differences in carbon intensity and plug them into the data set here so that,
- 57:51you know, we can refine our estimates as much as possible.
- 57:54Yeah.
- 57:54Yeah.
- 57:54And shout out to the cloud providers, provide more data.
- 57:58Yeah.
- 57:58To the CPU providers, provide more hooks, things like that.
- 58:02My hope for the project is that in a few years, we don't need this project anymore because we are doing
- 58:08estimation of estimation of estimation.
- 58:11There's better people in the industry, cloud providers and hardware vendors that are suited
- 58:17to get more precise data.
- 58:19But until then, I hope that the project can...
- 58:23Companies be aware of their mission, take action on that and allow the project to be more precise
- 58:29and give some estimation range for everything we are measuring.
- 58:33I feel like there are five to 10 companies in the world that can control all of the information
- 58:38you have.
- 58:38So we've got Intel, AMD, Apple for the chips.
- 58:42We've got AMD and NVIDIA for the cards and Azure, AWS, GCP.
- 58:49If they all provided more information, then this would be not much of an estimate, more of a measure.
- 58:54A couple of comments from the live stream.
- 58:57Corey Adkins says, thank you all.
- 58:59I've recommended this package to my ML team, which is awesome.
- 59:02And then Ryan Clark says, the efficiency varies widely between countries and whatnot.
- 59:08But you sort of addressed that already with your comment about trying to work to understand
- 59:14the different sources and how they...
- 59:16Even though they both look like coal, for example, they're actually not the same.
- 59:19Yeah, it's a really great question.
- 59:20And it really is something that we've relied on data from the US because we have the highest
- 59:25resolution of this and of the CO2 impact per energy consumed.
- 59:30And we have the most transparency about the numbers.
- 59:32It's not just a number in the end of a report or a footnote of a report.
- 59:38We can actually trace it and do some due diligence on that.
- 59:41So we've used those numbers.
- 59:42But if anybody listening to this or hearing this has a connection with any of those companies,
- 59:48the hardware companies, or knows how to get more energy data, we are always looking for
- 59:52collaborators and contributors.
- 59:53So please reach out to us.
- 59:55Yeah, fantastic.
- 59:56All right.
- 59:56I know we're pretty much at the end of our time together.
- 59:59So let me just ask you one really quick question.
- 1:00:01I have a thing I want to, a model I want to train.
- 1:00:04So I'm going to fire up a Docker image, maybe a set of them on Kubernetes and kick them off,
- 1:00:09let them go do their thing.
- 1:00:10Then I'm going to come back next week, have another idea that I'm going to train up some
- 1:00:14more things.
- 1:00:14Maybe my colleague is doing the same.
- 1:00:16This is going to generate a bunch of a mission.csv files.
- 1:00:19How do I correlate?
- 1:00:21How do I put these all together so that I can see like, as a team, this month is here we
- 1:00:26are.
- 1:00:26Is that something that happens?
- 1:00:27So I'm really glad you asked this question, because this is something we're working on.
- 1:00:33So currently, I think you can just sum up those CSV files.
- 1:00:37I think that's...
- 1:00:38Yeah, it's up to you to keep track and like say, okay, here's when we're sending in from
- 1:00:41this run.
- 1:00:42CSV files have a lot of downsides.
- 1:00:44It's less object oriented.
- 1:00:46And you could have a JSON file that would be more structured and so on.
- 1:00:49But at least it's very easily...
- 1:00:52You can just concatenate them, right?
- 1:00:54So...
- 1:00:54I think it's totally good, actually.
- 1:00:56It's more about the...
- 1:00:57It's going to be transient files in lots of places.
- 1:00:59How do I put them in one place so I see it as a whole?
- 1:01:02Yeah.
- 1:01:02What we've been working on lately with a team of volunteers in France with the dataforgood.fr
- 1:01:08initiative is to create and deploy an API in a database.
- 1:01:13So we want to create this online storage of the time series and not just the final sum and
- 1:01:20have that in a hierarchy of ownership from the organization to the single run through teams
- 1:01:29and projects.
- 1:01:29That requires a lot of work.
- 1:01:31That requires deployment.
- 1:01:33That requires fans and sponsors to host that thing.
- 1:01:36That requires a lot of engineering.
- 1:01:38And I'm glad you asked that question because I also wanted to have one word about open source
- 1:01:44and who's doing this.
- 1:01:46And it's all about volunteers.
- 1:01:48And no one is paid for that.
- 1:01:51companies like Comet or the Boston Consulting Group, who've been a partner for more than a year,
- 1:01:58do dedicate some software engineering time.
- 1:02:00And we need more collaborations.
- 1:02:02And if you think this tool is great and you want to use it, I think we would really appreciate
- 1:02:07if some of you had time to help because it's a small team of volunteers.
- 1:02:12I mean, it's the same for most open source projects out there and they need collaborators
- 1:02:17and contributors.
- 1:02:18And I think it's one of the things you can do also is help out.
- 1:02:24And most of it is pure Python, right?
- 1:02:27So chances are you're going to be able to help.
- 1:02:30And or if you if you don't know Python, there's some data collection issues.
- 1:02:35And it's just about writing to a CSV file.
- 1:02:38You just got to find the time to go fetch those numbers.
- 1:02:40There are data visualization issues to help improve the dashboard.
- 1:02:44And so on.
- 1:02:44So like it's it's never ending.
- 1:02:46So everyone can help.
- 1:02:47Yeah.
- 1:02:47Sounds like a really great project to get involved in if people are looking to find an open source
- 1:02:51thing to work on.
- 1:02:52And we're willing to onboard you, which also is sometimes bumpy in open source projects.
- 1:02:59And I think, I mean, it's hard and there are hundreds of guides of how to contribute to
- 1:03:04open source projects out there.
- 1:03:05I think we want people.
- 1:03:07So like if you we're going to help you help us.
- 1:03:10Yeah.
- 1:03:11Very cool.
- 1:03:11I encourage people to do so.
- 1:03:13All right.
- 1:03:13Final quick question before we get out of here.
- 1:03:15Brian Hermsen says, I know this would be a big ask, but I would love to see this as a
- 1:03:20built in profiler for CPU intensive ML libraries.
- 1:03:23Yeah.
- 1:03:23We just told you CPU is super hard.
- 1:03:25Exactly.
- 1:03:28Yeah.
- 1:03:28I mean, it's I think this is going to go beyond what we know and can do.
- 1:03:33But yeah, I agree with you.
- 1:03:34It should be part of more decisions in computer science in general and software engineering and
- 1:03:40hardware engineering and everything.
- 1:03:42All right.
- 1:03:43Let me ask you all the final two questions really quickly since there's three of you.
- 1:03:47You're going to write some Python code.
- 1:03:48What editor do you use?
- 1:03:50VS Code.
- 1:03:50Me too.
- 1:03:51Sublime.
- 1:03:51Sorry, guys.
- 1:03:52I used to be a sublime fan, but VS Code is good now.
- 1:03:56Yeah.
- 1:03:56I feel like a lot of the sublime people have moved on to VS Code, but sublime is still popular
- 1:04:00as well.
- 1:04:01Notable PyPI package.
- 1:04:02Maybe some cool library that works with some of the things you're all interested in.
- 1:04:08Just quick.
- 1:04:08Maybe people haven't heard of.
- 1:04:10I like rich, which is a super flexible, colorful, versatile tool to print stuff instead of writing
- 1:04:20again and again the same quacky print functions.
- 1:04:25They call it a TUI.
- 1:04:26A TUI.
- 1:04:27Do they have it in here?
- 1:04:28A TUI.
- 1:04:29Some now use interface.
- 1:04:30A terminal interface.
- 1:04:31It's so good.
- 1:04:32It's cool.
- 1:04:33It's incredible.
- 1:04:33Yeah.
- 1:04:34And I just want to also give a shout out to computational open source libraries like
- 1:04:40NumPy, scikit-learn, and Matplotlib, Pandas, and so on.
- 1:04:44Because those things run the data sense world, and it's all open source, non-profits, and
- 1:04:51it's a few maintainers, and they deserve a lot of the credit for the recent advances.
- 1:04:57They definitely do.
- 1:04:57Boris or John, either want to give a quick shout out to anything?
- 1:05:00If I will do some shameless marketing, I would say the CometML, Python SDK, but more, I would
- 1:05:06say as a FastAPI or some basis library that everyone uses, requests, and even just the
- 1:05:13Python standard library, I know some CPython core developers that are doing a tremendous
- 1:05:18job.
- 1:05:18It's a stainless job, so thank you to them.
- 1:05:21Yeah, for sure.
- 1:05:22To them.
- 1:05:22Yeah, everything Boris and Victor have recommended are great stuff.
- 1:05:26Yeah, fantastic.
- 1:05:27All right.
- 1:05:28Well, final call to action.
- 1:05:29People out there are listening.
- 1:05:31They're doing machine learning.
- 1:05:33They want to be able to use this to measure their work and maybe make some change.
- 1:05:37What do you say?
- 1:05:37Use it.
- 1:05:38Contribute.
- 1:05:39Evangelize.
- 1:05:40Share.
- 1:05:41I think most of the thing you can do about climate change is spreading awareness, discussing
- 1:05:48those things, and challenging the status quo.
- 1:05:50Yeah.
- 1:05:51Fantastic.
- 1:05:51All right, Boris, Victor, John, thank you all for being here.
- 1:05:54It's been really great to have you.
- 1:05:55Thanks so much for your time.
- 1:05:56Yeah, thanks for having us.
- 1:05:57Have a great day, everyone.
- 1:05:58Bye.
- 1:05:58Or evening, if you're in France.
- 1:06:00Exactly.
- 1:06:02Bye, all.
- 1:06:02Bye.
- 1:06:03Bye.
- 1:06:04This has been another episode of Talk Python To Me.
- 1:06:07Our guests on this episode have been Victor Schmidt, Jonathan Wilson, and Boris Feld.
- 1:06:11It's been brought to you by Square and us over at Talk Python Training.
- 1:06:15With Square, your web app can easily take payments, seamlessly accept debit and credit cards, as well
- 1:06:20as digital wallet payments.
- 1:06:22Get started building your own online payment form in three steps with Square's Python SDK
- 1:06:27at talkpython.fm/Square.
- 1:06:30Want to level up your Python?
- 1:06:32We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:06:37Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:06:42And best of all, there's not a subscription in sight.
- 1:06:44Check it out for yourself at training.talkpython.fm.
- 1:06:47Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:06:52We should be right at the top.
- 1:06:53You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:06:58and the direct RSS feed at /rss on talkpython.fm.
- 1:07:03We're live streaming most of our recordings these days.
- 1:07:06If you want to be part of the show and have your comments featured on the air,
- 1:07:09be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:07:14This is your host, Michael Kennedy.
- 1:07:16Thanks so much for listening.
- 1:07:17I really appreciate it.
- 1:07:18Now get out there and write some Python code.
- 1:07:20I really appreciate it.
- 1:07:41Thank you.