No GPU in labs. Should there be one?

I’ve noticed many times that our labs always run on CPU, which is why we never are able to train our models properly.

I thought the teachers knew this, but then I saw this line of code in the Week 1 programming assignment:

model = tl.Accelerate(model)

So, the assignment is trying to make sure the model runs on GPU.


import jax # the calculator behind trax.
for device in jax.local_devices():
print(f’Device: {device}')

output: Device: TFRT_CPU_0


David - Check if JAX is using GPU

if jax.devices()[0].platform == “gpu”:
print(“JAX is using a GPU.”)
print(“JAX is not using a GPU.”)

Output: JAX is not using a GPU.

Hey @David_Bangs,
Welcome, and we are glad that you could become a part of our community :partying_face: If you take a look at the documentation of tl.Accelerate, which can be found here, you will find that the aim of the function is not pertaining particularly to the GPU only. The aim of the function is to accelerate the layer which has been passed to it by using parallelisation. Although this can be done more efficiently using a GPU, since a GPU usually has more cores, but it can be done using a CPU as well, by using the multiple cores of a CPU.

So, I assume that this assignment is not intended to run on GPU, but on a CPU only. I hope this resolves your error.


Thank you. I’m still wondering whether the decision not to GPU-enable the labs is a a feature or a bug. The labs are slow and we can never train the models. I’m not sure what we are missing out on by not having GPU access. It seems like working with GPUs is a critical component of learning AI.

Perhaps Coursera has very few GPUs and they reserve them for very specific purposes?
In the graphics courses, which used PyTorch, we did enable GPU.

Hey @David_Bangs,

It’s neither a feature nor a bug, it’s a simple choice that has been made by DeepLearning.AI. I don’t think that Coursera has it’s own GPUs, instead, it uses cloud providers, mostly AWS. Now, for every assignment that uses a GPU, DeepLearning.AI needs to pay a hefty amount since there are more than 50K learners in the NLP specialization.

So, if DeepLearning.AI chooses to run the labs on GPUs, then they would have to increase the subscription that they charge from the learners, and I guess that’s the trade-off in which DeepLearning.AI chose to run the labs on CPUs only. Additionally, as you might have noticed, there are far more labs than there are assignments in the entire specialization, probably more than twice. So, if DeepLearning.AI currently pays say $20 for a learner’s access to GPUs throughout the entire specialization, in the later case, it would have to pay more than $60.

If you want to run the labs on GPUs, you can always download them and run them on either Colab or Kaggle, which provides access to free GPUs. I hope this resolves your query.


Thank you. Yes, that’s the info I was looking for. I’ve been experimenting with Google Colab and my own GPU also, and hope other students are doing so as well. GPUs vs CPUs is an important implementation detail. I think it should be discussed more.

Hey @David_Bangs,
If you don’t mind, can you please give some more feedback to me, so that I can pass it on to the team.

For instance, would you like implementation details regarding GPU/CPU in every lab and assignment, or would just the first lab or assignment of every course would suffice. I think the later should be more than enough, do let me know what you think :thinking:

Additionally, would you like details concerning only how to implement and train models on GPU/CPU, or more in-depth details, for instance, in the form of a video or reading item?

Thanks a lot in advance, for taking the additional time and efforts :smile:


I think an ideal AI class would discuss deploying AI models and practical considerations such as running them on GPUs and TPUs so that they can be useful.

It seems impractible to port these labs to other platforms. For example, the last lab contained multiple GB of support files rather than reading them from accessible URLs, and autograder tends to fail when the component versions aren’t the exact same versions that are installed on Coursera servers. For that reason, I’m considering taking the Machine Learning Crash Course from Google - because it is based on the Google Colab environment and I might be able to implement things that aren’t too slow to be useful.

I believe there are separate courses for those topics.

Sounds like a good match for your interests.

Hey @David_Bangs,
First of all, thanks a lot for the detailed feedback. As Tom pointed it out, there are separate courses for what you are seeking. This specialization is more focused towards educating the learners about NLP. You can check out the MLOps Specialization which could serve some of your stated needs.

As to this, it is indeed a genuine issue. Although the learners can run the assignments on Colab/Kaggle, once they have passed them, but they still need to download and upload the additional files on Colab or Kaggle, in order to run the assignments. Unfortunately, there are not many solutions for this. Even if DLAI uploads the additional files at some place from where you can read the files directly, they would still be accessible via your Coursera credentials, since they have to be locked behind a paywall, and once again, Colab or Kaggle won’t be able to read the files directly.

The good thing is that once you have learned how to run models on GPUs, there won’t be much difference from what we have already learnt in the course. Nonetheless, thanks once again for your detailed feedback :nerd_face:


Thank you. I know I’m almost done with the course and then will have time to explore many options on my own. I think the course is very unique and useful.

By the way, progressing through the course win Week 3 there was a surprise appearance of lectures on Hugging Face, and two practice labs on Google Colab using Hugging Face models. Hugging Face courses were recommended for people wanting to continue and to do some practical work with hugging face models after finishing the specialization.

This is really great.

Having finished the course, I can now make a suggestion:

I was in week 2 when I posed the question. In week 3, the course took a turn and did address the GPU issue. There were a couple of Hugging Face labs on Google Colab, and two of the lecture notebooks were available in Google Colab format.

The issue was addressed, so my suggestion would be to address it earlier.

I think there should be a graphic inserted at the beginning of the class explaining that some of the labs near the end of the lab will be conducted on Google Collab to give students experience running labs with GPUs, and also that some other lessons would include pre-trained data. This would have shifted my attitude as i took the course. I wouldn’t have spent my time looking for other courses.

What I learned from Google Collab is that the availability of GPUs is important, but doesn’t entirely transform the experience. It is not as if the models because fast enough just because there is a GPU. The strategy of importanting pretrained weights is still necessary and running the model still involves significant delays. Available Ram is a big problem, even on Google Colab.

By using the GPU, I gained a perspective that it is isn’t enough to achieve anything similar to what openai is able to achieve. This shifts my thinking about how to approach problems I want to work on.

Hey @David_Bangs,
Thanks a lot for your detailed feedback and suggestions. Let me pass these on to the team, and the team will update some content, or add an extra reading item, whatever they think might be the best for the learners.


Hey @David_Bangs,
A reading item addressing this issue has been added in Week 1 of this course. Thanks once again for your feedback.


Great, I see the slide added to week one of the fourth course.

I want to add that I accidentally looked in course one of the specialization and noticed the that four of the screens in Week 1 of Course 1 display as only the padlock symbol. I noticed this when I took the course, but just moved on.

Hey @David_Bangs,

Can you please elaborate more on this? I checked out Week 1 of Course 1, and everything seems fine to me. It would be great if you can attach some screenshots as well.