Trung DoanT
Windmill2y ago
7 replies
Trung Doan

Cannot import pytorch

Import torch causing Import Error. Any other packages is fine.

The code:
#requirements:
#torch==2.2.1

import torch
def main():
    return torch.cuda.is_available()


The error:
ExecutionErr: ExitCode: 1, last log lines:
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/windmill/wk-gpu-workers-dataserver-T6dCh/018e22e0-61d1-bd67-2925-09cfa5c37e83/wrapper.py", line 9, in <module>
    from u.trungdoan import cleanest_script as inner_script
  File "/tmp/windmill/wk-gpu-workers-dataserver-T6dCh/018e22e0-61d1-bd67-2925-09cfa5c37e83/u/trungdoan/cleanest_script.py", line 4, in <module>
    import torch
  File "/tmp/windmill/cache/pip/torch==2.2.1/torch/__init__.py", line 26, in <module>
    from ._utils import _import_dotted_name, classproperty
ImportError: cannot import name '_import_dotted_name' from 'torch._utils' (/tmp/windmill/cache/pip/torch==2.2.1/torch/_utils.py)


It doesn't say why it cannot import, so I don't know where to go from here.
Was this page helpful?