Majdoddin / nlp

MIT License
444 stars 57 forks source link

NameError: name 'torch' is not defined #5

Closed soliviantar closed 1 year ago

soliviantar commented 1 year ago

Hi, I'm trying to use the v2 Colab notebook but whenever I get to this section:

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipeline.to(device)

I get the following error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
[<ipython-input-22-eabb39154ab5>](https://localhost:8080/#) in <cell line: 1>()
----> 1 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
      2 pipeline.to(device)

NameError: name 'torch' is not defined

Not sure what I'm doing wrong. Any ideas? I believe I followed through all previous steps correctly.

sisland commented 1 year ago

Same error here with the last version of the Google Collab:

NameError                                 Traceback (most recent call last)
[<ipython-input-20-eabb39154ab5>](https://localhost:8080/#) in <cell line: 1>()
----> 1 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
      2 pipeline.to(device)

NameError: name 'torch' is not defined
JamJacques commented 1 year ago

@sisland @linguax-gc you just need to import torch before ;)

Screenshot 2023-05-17 at 11 38 37
Majdoddin commented 1 year ago

ty, it works now.