pytorch-seq2seq icon indicating copy to clipboard operation
pytorch-seq2seq copied to clipboard

Tutorial 3: failed to run in google colab

Open YiyiAm opened this issue 3 years ago • 6 comments

I tried to run tutorial 3 in google colab

It succeeded many days ago, but not today. I encountered an odd bug in the following code: from torchtext.datasets import TranslationDataset, Multi30k

ImportError: cannot import name 'TranslationDataset' from 'torchtext.datasets' (/usr/local/lib/python3.7/dist-packages/torchtext/datasets/init.py)

These codes ran well: import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F

What's wrong?

YiyiAm avatar Mar 11 '21 16:03 YiyiAm

funny, this problem has been solved by: !pip uninstall torchtext !pip install torchtext

and now the version is: torch==1.8.0 torchtext-0.9.0

YiyiAm avatar Mar 12 '21 02:03 YiyiAm

failed again with nothing changed, except for a reconnection

still not figure out what's happing , sad

YiyiAm avatar Mar 12 '21 05:03 YiyiAm

## always follow this sequence: ## first connect and set GPU

## run these: # !pip uninstall torchtext # !pip install -U torchtext==0.8.0 ## agree to restart, ## run your pytorch program first,until you see bug report: xxx undefined

## then run these: # !pip uninstall torchtext # !pip install torchtext ## agree to restart

## then run these # !python -m spacy download en # !python -m spacy download de ## then you can run the code normally ## reason unknown

YiyiAm avatar Mar 12 '21 06:03 YiyiAm

These bugs are because of some big API changes in torchtext between versions 0.8 and 0.9.

I need to update the tutorials appropriately, but haven't yet had the chance to do so. I will work on it this weekend.

bentrevett avatar Mar 12 '21 12:03 bentrevett

These bugs are because of some big API changes in torchtext between versions 0.8 and 0.9.

I need to update the tutorials appropriately, but haven't yet had the chance to do so. I will work on it this weekend.

Thank you

YiyiAm avatar Mar 12 '21 12:03 YiyiAm

This should now be fixed.

If you're using PyTorch 1.8 and torchtext 0.9 then the master branch should work.

If you're using PyTorch 1.7 and torchtext 0.8 then the torchtext08 branch should work.

Please let me know if you encounter any more issues and I'll try and fix them ASAP.

bentrevett avatar Mar 12 '21 13:03 bentrevett