Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Having issue converting model from dpt_scriptable branch #51

Closed
InfiniteLife opened this issue Oct 11, 2021 · 3 comments
Closed

Having issue converting model from dpt_scriptable branch #51

InfiniteLife opened this issue Oct 11, 2021 · 3 comments

Comments

@InfiniteLife
Copy link

I'm trying to run convertantion, but having this error:

initialize
device: cuda
Traceback (most recent call last):
  File "run_monodepth.py", line 245, in <module>
    args.optimize,
  File "run_monodepth.py", line 114, in run
    model = torch.jit.script(model)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_script.py", line 1097, in script
    obj, torch.jit._recursive.infer_methods_to_compile
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 412, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 474, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_script.py", line 497, in _construct
    init_fn(script_module)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 452, in init_fn
    scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 478, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 355, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 820, in compile_unbound_method
    create_methods_and_properties_from_stubs(concrete_type, (stub,), ())
  File "C:\Users\Ilya\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 355, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
RuntimeError:
Module 'VisionTransformer' has no attribute 'dist_token' :
  File "D:\dev\Mars\DPT-dpt_scriptable\dpt\vit.py", line 274
        x = self.model.patch_embed.proj(x).flatten(2).transpose(1, 2)

        if hasattr(self.model, "dist_token") and self.model.dist_token is not None:
                                                 ~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            cls_tokens = self.model.cls_token.expand(
                B, -1, -1
'BackboneWrapper.forward_flex' is being compiled since it was called from 'BackboneWrapper.forward'
  File "D:\dev\Mars\DPT-dpt_scriptable\dpt\vit.py", line 300
        _, _, h, w = x.shape

        layers = self.forward_flex(x)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE

        # HACK: this is to make TorchScript happy. Can't directly address modules,

I'm using models fromd dpt_scriptable branch.

@InfiniteLife
Copy link
Author

Turns out I had older version of Python. Solved by upgrading Python.

@romil611
Copy link

romil611 commented Nov 15, 2021

@InfiniteLife which version are you using now? I'm using torch 1.8 and still facing the exact issue.

@hgchen
Copy link

hgchen commented Oct 10, 2022

I believe the error due to timm version, not pytorch. pip install timm=0.4.9 solved this problem for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants