No module named 'torch._six'
cdeepali opened this issue ยท 8 comments
๐ 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
I'm facing the same issue, did you find any solution?
I did pip install --upgrade torch torchvision
and it works
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.
---------------------------------------------------------------------------
@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)
@rbhernandez thanks for the input. Do you know which version of pl_bolts work for 2.0.0+cu118?
Thanks again for the help!
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
.
@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
@rbhernandez Please upgrade lighting_bolts rather than ask user to downgrading torch,
- torch2.0 is now stable, and it must be most users choice now, please upgrade to it;
- if you want compatible with older torch, just make a judgement on version to import