Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'torch._six' #992

Closed
cdeepali opened this issue Mar 17, 2023 · 8 comments · Fixed by #993
Closed

No module named 'torch._six' #992

cdeepali opened this issue Mar 17, 2023 · 8 comments · Fixed by #993
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@cdeepali
Copy link
Contributor

🐛 Bug

import pl_bolts fails with the following error:

  File "<mypath>/test_tmp/run_test.py", line 2, in <module>
    import pl_bolts
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/__init__.py", line 11, in <module>
    from pl_bolts import (  # noqa: E402
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/callbacks/__init__.py", line 6, in <module>
    from pl_bolts.callbacks.ssl_online import SSLOnlineEvaluator
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/callbacks/ssl_online.py", line 12, in <module>
    from pl_bolts.models.self_supervised.evaluator import SSLEvaluator
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/models/self_supervised/__init__.py", line 21, in <module>
    from pl_bolts.models.self_supervised.cpc.cpc_module import CPC_v2
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/models/self_supervised/cpc/__init__.py", line 1, in <module>
    from pl_bolts.models.self_supervised.cpc.cpc_module import CPC_v2
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/models/self_supervised/cpc/cpc_module.py", line 14, in <module>
    from pl_bolts.datamodules.stl10_datamodule import STL10DataModule
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/datamodules/__init__.py", line 1, in <module>
    from pl_bolts.datamodules.async_dataloader import AsynchronousLoader
  File "<myenv>/lib/python3.10/site-packages/pl_bolts/datamodules/async_dataloader.py", line 9, in <module>
    from torch._six import string_classes
ModuleNotFoundError: No module named 'torch._six'

See - pytorch/pytorch#94709

@cdeepali cdeepali added the help wanted Extra attention is needed label Mar 17, 2023
@rehammsalah
Copy link

I'm facing the same issue, did you find any solution?

@rbhernandez
Copy link

I did pip install --upgrade torch torchvision and it works

@devdastl
Copy link

devdastl commented Apr 13, 2023

Thanks @rbhernandez that solved while import from pl_bolts.models but while importing pl_bolts.datamodules I am again getting torch.six error

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-19-fbbe43d17848>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from pl_bolts.datamodules import CIFAR10DataModule
      2 
      3 datamodule = CIFAR10DataModule('.')

7 frames
[/usr/local/lib/python3.9/dist-packages/pl_bolts/datamodules/async_dataloader.py](https://localhost:8080/#) in <module>
      7 import torch
      8 from torch import Tensor
----> 9 from torch._six import string_classes
     10 from torch.utils.data import DataLoader, Dataset
     11 

ModuleNotFoundError: No module named 'torch._six'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

@rbhernandez
Copy link

rbhernandez commented Apr 13, 2023

@devdastl you can try upgrade lighting_bolts. Torch2.0 is now stable, and it must be most users choice now.
If you want compatible with older torch, just make a judgement on version to import.

Originally posted by @lucasjinreal in #992 (comment)

@devdastl
Copy link

@rbhernandez thanks for the input. Do you know which version of pl_bolts work for 2.0.0+cu118?
Thanks again for the help!

@Wheest
Copy link

Wheest commented Apr 19, 2023

I'm also experiencing this issue with PyTorch 2.0.0+cu118, with pl_bolts version 0.6.0.post1. I had to downgrade to torch==1.13.0.

@Borda Borda reopened this Apr 19, 2023
@devdastl
Copy link

@Wheest
Since I was using colab, I found out it was more difficult to downgrade So I just changed that line in source code with string_classes = str in /usr/local/lib/python3.9/dist-packages/pl_bolts/datamodules/async_dataloader.py

@Borda is this the correct solution? Should we replace from torch._six import string_classes with string_classes = str

@lucasjinreal
Copy link

lucasjinreal commented May 15, 2023

@rbhernandez Please upgrade lighting_bolts rather than ask user to downgrading torch,

  1. torch2.0 is now stable, and it must be most users choice now, please upgrade to it;
  2. if you want compatible with older torch, just make a judgement on version to import

@Borda Borda added fix fixing issues... bug Something isn't working and removed fix fixing issues... labels Jun 20, 2023
@Borda Borda closed this as completed Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants