question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method 'forward' is not defined

See original GitHub issue

I installed the module via

$ pip install deep-daze

and just tried the provided example with

$ imagine "a house in the forest"

but after it loaded something for a few minutes (the first time I run the command) it throws this error

Traceback (most recent call last):
  File "/home/luca/anaconda3/bin/imagine", line 5, in <module>
    from deep_daze.cli import main
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/__init__.py", line 1, in <module>
    from deep_daze.deep_daze import DeepDaze, Imagine
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/deep_daze.py", line 39, in <module>
    perceptor, normalize_image = load()
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/clip.py", line 192, in load
    model.apply(patch_device)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  [Previous line repeated 3 more times]
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 474, in apply
    fn(self)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/clip.py", line 183, in patch_device
    graphs = [module.graph] if hasattr(module, "graph") else []
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/jit/_script.py", line 449, in graph
    return self._c._get_method("forward").graph
RuntimeError: Method 'forward' is not defined.

My system is:

Ubuntu 18.04.4 LTS GeForce RTX 2070 pytorch 1.7.1 python version 3.7.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
lucidrainscommented, Mar 11, 2021

it turns out the released OpenAI code has some issues with the JIT version https://github.com/openai/CLIP/issues/49 I’ve submitted a new issue asking for them to make CLIP pip-installable, and I’ll fix it so it uses the non-JIT version instead once they do https://github.com/openai/CLIP/issues/60

1reaction
constantupgradecommented, Mar 13, 2021

Yep, using the updated files worked for me. Thanks for being so responsive and quick to solving these issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

RuntimeError: Method 'forward' is not defined. #49 - GitHub
Hi, I need to use a nightly version of PyTorch in order to get GPU support for my RTX 3080, and am facing...
Read more >
[pytorch Android] I got the error “Method 'forward' is not ...
[pytorch Android] I got the error “Method 'forward' is not defined.”, but I defined 'forward' function in my model. I implemented the resnet18 ......
Read more >
Pytorch model training without using forward - Stack Overflow
My suspicion is PyTorch only able to propagate the gradient through the forward method. Some source says that forward is not that special...
Read more >
Common issues and solutions - mypy 0.991 documentation
NameError : name "X" is not defined from forward references. TypeError: 'type' object is not subscriptable from types that are not generic at...
Read more >
What's New In Python 3.10 — Python 3.11.1 documentation
They are used to forward the parameter types of one callable to another callable – a pattern commonly found in higher order functions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found