Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuntimeError when initialising from scratch #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yashbonde
Copy link

@yashbonde yashbonde commented Mar 3, 2021

When initialising from scratch, requires_grad is passed and then normal_ is called as below

w = torch.empty( ... , requires_grad=self.requires_grad)
w.normal_(std=1 / math.sqrt(self.n_in * self.kw ** 2))

Causing the following issue:

/usr/local/lib/python3.7/dist-packages/dall_e/utils.py in __attrs_post_init__(self)
     22                 size = (self.n_out, self.n_in, self.kw, self.kw)
     23                 w = torch.empty(size=size, dtype=torch.float32, device=self.device, requires_grad = self.requires_grad)
---> 24                 w.normal_(std=1 / math.sqrt(self.n_in * self.kw ** 2))
     25 

RuntimeError: a leaf Variable that requires grad is being used in an in-place operation.

The current change fixes it.

When initialising from scratch, `requires_grad` is passed and then `normal_` is called as below
```
w = torch.empty( ... , requires_grad=self.requires_grad)
w.normal_(std=1 / math.sqrt(self.n_in * self.kw ** 2))
```

Causing the following issue:
```
/usr/local/lib/python3.7/dist-packages/dall_e/utils.py in __attrs_post_init__(self)
     22                 size = (self.n_out, self.n_in, self.kw, self.kw)
     23                 w = torch.empty(size=size, dtype=torch.float32, device=self.device, requires_grad = self.requires_grad)
---> 24                 w.normal_(std=1 / math.sqrt(self.n_in * self.kw ** 2))
     25 

RuntimeError: a leaf Variable that requires grad is being used in an in-place operation.
```

The above change fixes it.
@mazzzai
Copy link

mazzzai commented Mar 3, 2021

hello yashbonde!

do you know how can i launch DALL-E?

i have macos high sierra / jupiter / phyton3 / notebook and i'm the beginner)

here some stuff
https://disk.yandex.ru/i/kCSzh6LodRkWlQ

can you help me?

screenshots
Снимок экрана 2021-03-03 в 16 35 14

Снимок экрана 2021-03-03 в 16 35 30

Снимок экрана 2021-03-03 в 16 35 43

@yashbonde
Copy link
Author

yashbonde commented Mar 3, 2021

I am not sure what is the exact problem, notebook is working just fine. But if it persists, consider raising an issue

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

Successfully merging this pull request may close these issues.

2 participants