Andrej Karpathy on PyTorch at Tesla


What Karpathy talks about
Andrej Karpathy gave this conference talk in February 2018 on Tesla’s use of PyTorch for Autopilot, covering autonomy, data pipelines, model training, and deployment across its vehicle fleet.
Andrej Karpathy walks through Tesla’s approach to self-driving AI, focusing on how PyTorch supports the full lifecycle of Autopilot development. He explains how Tesla builds perception systems from raw video, trains large multi-task networks, and deploys them to a massive fleet of vehicles.
He emphasizes the engineering complexity behind autonomy: hundreds of predictions, many coordinated networks, memory-heavy training, and the need for both data parallelism and model parallelism. The talk shows why Tesla treats autonomy as an end-to-end systems problem, not just a model-training problem.
Karpathy speaks throughout, with no other speaker turns in the transcript.
In his words
“We don't use lidar and we don't use high-definition maps”
“Everything that we built for the autopilot is basically based on computer vision, machine learning, on the raw video streams”
“The North Star for the team is something we internally somewhat jokingly refer to as operation vacation”
“So if you had a single node with 8 GPUs, you would be training for a year”
“And so it's incredible to work on such a, such an interesting product”
Key points
- Tesla’s Autopilot is built from computer vision and machine learning on raw video from eight cameras, not lidar or HD maps.
- The team uses shared-backbone, multi-head networks Karpathy calls HydraNets to handle many perception tasks efficiently.
- Tesla stitches predictions across space and time using recurrent processing and top-down representations like occupancy grids.
- Training is expensive and complex: many tasks, large unrolled graphs, and memory limits push beyond simple distributed data parallelism.
- Tesla trains and validates the full stack in-house, including labeling, calibration, evaluation, and deployment to the fleet.
- Karpathy says Tesla aims for an internal “operation vacation” where the system improves continuously with minimal manual intervention.
- He also briefly mentions Tesla’s custom inference hardware and Dojo as a future training system.
Full transcript: Andrej Karpathy, PyTorch at Tesla (2018)
Okay, hello everyone. I am Andre. I am the director of AI at Tesla, and I'm very excited to be here to tell you a little bit about PyTorch and how we use PyTorch to train your all networks for the autopilot. Now, I'm Pierce. To do a bit of a show of hands, how many of you actually own a Tesla? Okay, a few. And how many of you have used or experienced the autopilot product? Okay, thank you. Yeah, so let's see. So for those of you who may not be familiar with autopilot, the basic functionality of the autopilot is that it keeps the car in the lane and it keeps the car also away from the
vehicle waiting ahead of you. And then some of the more advanced functionality that we've been building for the autopilot includes navigating on autopilot, which allows you to set down a pin somewhere on the map, and then as long as you stick to highway, the car will do all of the lane changes automatically and it will take all the right forks to get you there. So that's navigating autopilot. With Smart Summon, which we only released about two weeks ago, you can summon the car to you in the parking lot. So you hold down "come to me," and the car comes out of its parking spot and it will come find you in the parking lot. You get in like royalty, and it's an amazing magical feature. More broadly, the team is very interested in pursuing kind of developing full self-driving capability, so that's what everyone is focused on in
the team now. Famously, perhaps, we don't use lidar and we don't use high-definition maps. So everything that we built for the autopilot is basically based on computer vision, machine learning, on the raw video streams that come from the eight cameras that surround the vehicle. So this is an example of what we might see in one single instant, and we process this, as you might imagine, with a lot of convolutional networks. Now, Tesla is a fairly vertically integrated company, and that's also true when it comes to the intelligence of the autopilot. So in particular, of course, we build our own cars and we arrange the sensors around the vehicle, but then also we collect all of our data, we label all of the data, we train it on on-premise GPU clusters, and then of course we take it through the entire stack. We run these
networks on our own custom hardware that we develop in-house, and then of course we are in charge of the full lifecycle of these features. So we deploy them to our fleet of almost three-quarters of a million cars right now, and we look at telemetry and try to improve the feature over time, so we kind of close the loop on this. So I would like to slightly dive into some of the distribution that we employ in the team. So the bread and butter for us is, of course, analyzing images. So here's an image. In order to drive in this environment, you actually have to understand a lot about this environment. So perhaps we have to understand the traffic lights, the lane line markings, cars, and so on. So you end up in this very massively multitask setting very quickly where you just have to know a lot about the scene, so all over a lot of
our networks take on this outline here, where you have kind of a shared backbone that has a number of tasks hanging off of it. And just to give you an idea of the workflows in the kinds of networks, these are typically a ResNet-50-like backbone running on roughly a thousand, five thousand images, and then they have these heads, these structures, that make sense. And of course, we're doing this partly because we can't afford to have neural networks for every single task because there's many, many tasks, almost almost 100 tasks, and so we have to amortize some of that computation. So we put the most shared backbones. So here's some examples of what these networks that we call HydraNets because of their shared backbone and multiple heads, what these HydraNets might look like is this video playing. It's not. Okay, I'm just going to go to the next
video. That was going to show you some lane line markings and so on. This is a video showing you some road edges that we are interested in for the purposes of Smart Summon because we have to understand where we can be in in this environment, so we want to avoid the curbs in this case. Now here we are making predictions in the image, and then we are of course casting them out and stitching them up across space and time to understand a sort of the layout of the scene around us. So here's an example of this occupancy grid. We're showing just the road edges and how they get projected and the car winds its path around this parking lot while the person is summoning it, and it's just trying to find its way towards the goal through this parking lot. So here's how things get stitched up now. So far, if I've only talked about neural networks that run on independent images, but of course very quickly you run
across tasks that actually have to be a function of multiple images at the same time. So for example, if you're trying to estimate depth of any of these images, it might actually be very helpful to have access to the other views of that same scene in order to predict the depth at every individual pixel. Or if you're trying to predict the road layout, or if you're trying to steer the wheel or something like that, you might actually need to borrow features from multiple other HydraNets. So what this looks like is we have all of these different HydraNets for different cameras, but then you might want to pull in some of the features from these HydraNets and go to a second round of processing, optionally recurrent, and actually produce something like a road layout prediction. So this is an example of what a road layout prediction might look like for the autopilot. Here we are plugging in three cameras simultaneously into a neural network, and the network's predictions are not anymore in the image space; they
Are in the top-down space. So we're looking at the predictions of this network in particular. Here, we are showing some of the predictions related to the corridors that are available in this parking lot, where the intersections are, and what the orientations of all of these things are. And so the stitching up now doesn't happen sort of in a C++ code base. The stitching up across space and time happens inside the recurrent neural network. So more generally, what our networks start to look like for all of these different tasks, and what we're converging on, is it looks something like this: We have eight Hydra nets for the Aged tasks, and they all produce all kinds of intermediate predictions. But in addition to that, the features from these Hydra nets go into a second round of processing, there's potentially recurrent, and then we have more outputs that are sort of in a top-down view. And then what's special about this is that this is, of course, like a pretty large single network, and every single task
sub-samples parts of this network and trains just that small piece. So, for example, we can be training object detector online with cameras, or we can be training a depth network, or we can be training or layout network. All these tasks subsample the graph and train only that portion. And then if you've trained Ricola neural network, some videos, you'll quickly kind of notice that these are not trivial training; we're closed. So as an example, if I want to back unroll this graph in time and back propagate through time, maybe we have eight cameras, we unroll for 16 time steps, use a batch size of, say, 32, then we are going to be holding in memory 4,096 images and all of their activations in a single forward pass. So very quickly your typical distributed data parallel will break, because you can't hold this amount of memory, this amount of activations in
memory of a single GPU or even a single node. So a lot of our training potentially has to combine some elements of data distribute this, this real data parallel, but also model parallelism and so on. It also gets kind of tricky in terms of training these networks, because the typical simplest case might be a round-robin training of different tasks. So you're training task one, then over all the workers in the pool are training task one, then task two, three, etc. That gets out of hand when you have a hundred tasks. So instead, what might make sense is to actually have a pool of tasks, and some of the tasks are doing objects, some of the tasks are doing road layout—sorry—some of the workers might be doing depth, and so on. And these are all very heterogeneous workflows, but they coexist and they're training different pieces of the network at the same time. And then you can arrange them in synchronous asynchronous way or play
with this to really get squeezed out all the juice out of it. But all in all, if you're trying to train all of the neural networks for the autopilot, it is actually a fairly expensive task. In particular, today we would train 48 different networks that make 1,000 different predictions—just if you count the number of output tensors—and it takes 70,000 GPU hours to train to compile the autopilot. It leaves the neural network stack. So if you had a single node with 8 GPUs, you would be training for a year. So it's a lot of networks and a lot of predictions, and a lot of them must work and none of them can regress ever. And then you're not just training this once—you have to iterate on this. So of course, there are researchers and engineers in the team that actually have to improve on this. And so, as you can imagine, we do a lot of neural hour training
at scale to get this to actually work. And then we are automating a lot of the workflows. It's not just about the neural network training itself but everything surrounding that. So in particular, we have to calibrate all the different thresholds. We have a process for that. We have a lot of in-the-loop valve, from our loop validation, other type of validation and evaluation to make sure that none of these 1,000 different predictions that we make can regress and so on. And so the North Star for the team, though, is all of this can actually be automated quite well. So starting with the data set, you can train all the neural nets, you can do all the calibration, the evaluation, and you can really start to see the continuous integration of this. And so the North Star for the team is something we internally somewhat jokingly refer to as operation vacation. And the idea is that as long as the data labeling team is around and they're curating and
improving our data sets, then everything else can in principle be automated. And so we could actually go on a vacation and the autopilot improves by default. So that's something that we really try to try to go towards in the team. I would like to also talk a little bit about the inference aspect of this. So because I talked quite a bit about training, as I mentioned, we have sort of our own back-end that our Hardware team has developed. We call this the FST computer. It offers about 144 INT8 tera-ops off capability compared to the GPUs that we were using before. We introduced this chip. This is roughly an order of magnitude improvement with lower cost. So we use this in all the latest cars that are now coming out of the production line, and we target all the neural networks to these chips. And the last thing I wanted to also briefly allude to
As you'll notice here on the bottom, we have a GPU cluster. The hardware team is also working on a project we call Dojo. And a Dojo is a neural network training computer and a chip. And so we hope to do the exact same thing for training as we did for inference: improve basically the efficiency by roughly an order of magnitude at a lower cost. But I'm not ready to talk about more details in that project just yet. So in summary, I talked about the full lifecycle of developing these neural hours for the autopilot and how we own everything in-house. The neural network is actually fairly complicated and large, and we deal with a lot of problems if we actually want to train the beast, but it's giving us some very interesting results. And the nice thing about this is not only do we get to train really awesome large networks, but we also
to ship them. And so, for example, navigating autopilot has now accumulated 1 billion miles. We've confirmed 200,000 lane changes, and this is a global product across 50 countries or more now. And so that's a lot of forward passes out there of neural networks. And with Smart Summon, this is actually a bit of an outdated number: we now had 800,000 sessions of people trying to call their car to them. And so it's incredible to work on such a, such an interesting product. Finally, I would like to thank the Patrasche team for being incredibly responsive and helpful and sort of allowing us to develop all these networks and really train them at scale and then deploy in the real world. It has been really an interesting collaboration. Thank you.
(applause) (music)
From YouTube captions, lightly punctuated for readability. Timestamps link to the video above. Errors are possible.
Cite this recording
Andrej Karpathy, “PyTorch at Tesla (2018)”, conference keynote / industry talk, February 2018. Transcript and video: Thinkers Archive, https://thinkersarchive.com/andrej-karpathy/pytorch-at-tesla-2018/
Quoting a passage? Link to its exact moment: every timestamp above has its own anchor (for example https://thinkersarchive.com/andrej-karpathy/pytorch-at-tesla-2018/#t-130).