# I don't think the GPU is available

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%3E%5C
**Category:** Beginners\
**Created:** [February 7, 2024, 10:18am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241 "2024-02-07T10:18:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AltShift](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AltShift](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAltShift)%5C
**Post date:** [February 7, 2024, 10:18am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%2F1 "2024-02-07T10:18:10Z")

</div>

I am on the “Fine-tuning a model with the Trainer API” step of Chapter 3 of the NLP Course.

I read, somewhere earlier, that Google Colab makes a GPU available for free. At the point where the Trainer is invoked, the tutorial says, “This will start the fine-tuning (which should take a couple of minutes on a GPU)”. When I tried this step in the Colab notebook, it took several hours.

Does this mean that the GPU is no longer free in Colab, or is there a missed step that I need to know about?

---

<div class="post-metadata">

**Author:** ![AltShift](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AltShift](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAltShift)%5C
**Post date:** [February 7, 2024, 10:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%2F2 "2024-02-07T10:19:40Z")

</div>

Nb. I am familiar with Jupyter notebooks but am fairly new to Colab and a total LLM newbie.

---

<div class="post-metadata">

**Author:** ![CKeibel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ckeibel/32/55416_2.png) [@CKeibel](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FCKeibel)%5C
**Post date:** [February 7, 2024, 10:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%2F3 "2024-02-07T10:31:31Z")

</div>

Hi @AltShift!  
You can change the run time environment of a colab notebook as explained in this [video](https://www.youtube.com/watch?v=-9CLfrZISRw&t=1s).

When connected to the new runtime you can check if cuda is available with the following code snipped

```auto
import torch
print(torch.cuda.is_available())

```

alternatively you can define a device if you need to pass it:

```auto
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

```

print(device)

---

<div class="post-metadata">

**Author:** ![AltShift](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AltShift](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAltShift)%5C
**Post date:** [February 17, 2024, 2:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%2F4 "2024-02-17T02:50:36Z")

</div>

Thanks @CKeibel !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [February 17, 2024, 2:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fi-dont-think-the-gpu-is-available%2F72241%2F5 "2024-02-17T14:51:34Z")

</div>

Closed on February 17, 2024, 2:51pm UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
