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

training with stylegan2 RuntimeError: derivative for aten::grid_sampler_2d_backward is not implemented #11

Open
aduchon opened this issue Jan 5, 2023 · 5 comments

Comments

@aduchon
Copy link

aduchon commented Jan 5, 2023

love the promise of this, but

in a colab
! !python /content/vision-aided-gan/stylegan2/vision-aided-gan.py --outdir {experiment_dir} \ --data {dataset_dir} --cfg paper256_2fmap --mirror 1 \ --aug ada --augpipe bgc --augcv ada --batch 16 --gpus 1 \ --kimgs-list '1000,1000,1000' --num 3

lots of
/content/vision-aided-gan/stylegan2/torch_utils/ops/conv2d_gradfix.py:55: UserWarning: conv2d_gradfix not supported on PyTorch 1.13.0+cu116. Falling back to torch.nn.functional.conv2d(). warnings.warn(f'conv2d_gradfix not supported on PyTorch {torch.__version__}. Falling back to torch.nn.functional.conv2d().')
and
File "/usr/local/lib/python3.8/dist-packages/torch/autograd/__init__.py", line 197, in backward Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass RuntimeError: derivative for aten::grid_sampler_2d_backward is not implemented

with
!python /content/vision-aided-gan/stylegan2/train.py --outdir {experiment_dir} \ --data {dataset_dir} --cfg paper256_2fmap --mirror 1 \ --aug ada --augpipe bgc --augcv ada --batch 16 --gpus 1
RuntimeError: derivative for aten::grid_sampler_2d_backward is not implemented

with
!python /content/vision-aided-gan/stylegan3/train.py --outdir {experiment_dir} \ --data {dataset_dir} --kimg 4000 --cfg stylegan3-t --gpus 1 --gamma 10 \ --batch 16 --cv input-clip-output-conv_multi_level \ --cv-loss multilevel_sigmoid_s --mirror 1 --aug ada --warmup 5e5

File "/content/vision-aided-gan/stylegan3/torch_utils/ops/grid_sample_gradfix.py", line 59, in forward grad_input, grad_grid = op(grad_output, input, grid, 0, 0, False) TypeError: 'tuple' object is not callable

@nupurkmr9
Copy link
Owner

Hi,
I think this error is because of stylegan2/3 code being incompatible with newer versions of PyTorch, example here.
Can you try with a lower version of PyTorch e.g., 1.10.0? Let me know if this resolves this issue.
Thanks.

@RanQChi
Copy link

RanQChi commented Jan 12, 2023

Hi, I think this error is because of stylegan2/3 code being incompatible with newer versions of PyTorch, example here. Can you try with a lower version of PyTorch e.g., 1.10.0? Let me know if this resolves this issue. Thanks.

not work for 1.10.0, it should work for 1.9.1.

@aduchon
Copy link
Author

aduchon commented Jan 12, 2023

I was able to get it to run stylegan3 (only) installing things in this order on a colab with gpu.
!git clone https://github.com/nupurkmr9/vision-aided-gan.git !pip install clip@git+https://github.com/openai/CLIP.git !pip install wandb !pip install clean-fid !pip install ninja !pip install vision_aided_loss !pip install lpips !pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
But, the results weren't great, just getting some wavy circles, so there must be some other parameters or something.

@RanQChi
Copy link

RanQChi commented Jan 13, 2023

Hello~ it works for me~ install the gxx=8.5 first then go with the torch 1.13+ cuda11.6 + ninja. Down with above, changed the tensorboard init, then changed the grid_sample_gradfix and conv2d_gradix also changed the sentence of the torch version in stylegan.

The reason is just the modification of the op (grid_sampler_2d_bacward) changed for different pytorch version. Past version only use the op=xxxx current version changed into a tuple as op,_=xxx and the input add a output mask composed by ctx_input1and ctx_input2.

vsemecky/stylegan3@f61d77a

@ganguliSilva
Copy link

What does you mean by "Down with above, changed the tensorboard init, " and how to do it?

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

No branches or pull requests

4 participants