Windows run MNIST example gets `AttributeError: module 'torch' has no attribute 'torch_version'`
See original GitHub issueDescribe the bug
On windows 10 platform, try to run MNIST example, got an error AttributeError: module 'torch' has no attribute 'torch_version'
. The error is located at file utils/tokenizers.py
, line 892, as follows,
# utils/tokenizers.py
892 if torch.torch_version.TorchVersion(torchtext.__version__) >= (0, 12, 0):
To Reproduce
On windows, use pipenv install ludwig
to install the ludwig(v0.5). Then, use ludwig datasets download mnist
to download the MNIST dataset and process. There are actually some issues related to Windows paths, but I’ve avoided them. After that, create the config.yaml
to configure the model and training exactly same as shown in the official docs. Finally, when use 'ludwig train --datasets mnist_datasets.csv --config config.yaml`, I got the error above.
config.yaml
is exactly the same as in the official docs.
input_features:
- name: image_path
type: image
encoder: stacked_cnn
conv_layers:
- num_filters: 32
filter_size: 3
pool_size: 2
pool_stride: 2
- num_filters: 64
filter_size: 3
pool_size: 2
pool_stride: 2
dropout: 0.4
fc_layers:
- output_size: 128
dropout: 0.4
output_features:
- name: label
type: category
trainer:
epochs: 5
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: Windows
- Version: 10
- Python version: 3.9
- Ludwig version: 0.5
Additional context
Full Error Stack:
Traceback (most recent call last):
File "D:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\Scripts\ludwig.exe\__main__.py", line 7, in <module>
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\cli.py", line 158, in main
CLI()
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\cli.py", line 63, in __init__
getattr(self, args.command)()
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\cli.py", line 66, in train
from ludwig import train
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\train.py", line 23, in <module>
from ludwig.api import LudwigModel
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\api.py", line 38, in <module>
from ludwig.backend import Backend, initialize_backend
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\backend\__init__.py", line 20, in <module>
from ludwig.backend.base import Backend, LocalBackend
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\backend\base.py", line 25, in <module>
from ludwig.models.ecd import ECD
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\models\ecd.py", line 10, in <module>
from ludwig.combiners.combiners import Combiner, get_combiner_class
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\combiners\combiners.py", line 25, in <module>
import ludwig.marshmallow.marshmallow_schema_utils as schema
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\marshmallow\marshmallow_schema_utils.py", line 8, in <module>
from ludwig.modules.reduction_modules import reduce_mode_registry
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\modules\reduction_modules.py", line 19, in <module>
from ludwig.modules.attention_modules import FeedForwardAttentionReducer
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\modules\attention_modules.py", line 21, in <module>
from ludwig.utils.torch_utils import get_activation, LudwigModule
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\utils\torch_utils.py", line 12, in <module>
from ludwig.utils.strings_utils import SpecialSymbol
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\utils\strings_utils.py", line 30, in <module>
from ludwig.utils.tokenizers import tokenizer_registry
File "C:\Users\houlu\.virtualenvs\Ludwig-APhWrIpG\lib\site-packages\ludwig\utils\tokenizers.py", line 893, in <module>
if torch.torch_version.TorchVersion(torchtext.__version__) >= (0, 12, 0):
AttributeError: module 'torch' has no attribute 'torch_version'
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks @houluy for the quick response!
Depending on when you installed Ludwig, it is possible that its package requirements were outdated. They should be fixed by #1998.
In any case, I recommend running
pip install -U torch torchtext torchvision torchaudio
within your virtual environment to get the most recent version of those dependencies.@geoffreyangus Thanks for your help!
I reinstall the latest version of
torch
(GPU) packages, and it works. Thanks again for your time!Here’s my
Pipfile
file in case others run into the same issue and can refer to it