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

High version Pytorch might lead to totally wrong result #35

Open
NaNillll opened this issue Feb 10, 2022 · 4 comments
Open

High version Pytorch might lead to totally wrong result #35

NaNillll opened this issue Feb 10, 2022 · 4 comments
Labels
good first issue Good for newcomers

Comments

@NaNillll
Copy link

I try torch==1.7 and torch==1.9, and run test.sh as readme shows. No warning. But, the result is so bad:

微信图片_20220210202036

Same as #32

However, when I switch to torch==1.4, the result is as good as paper shows.

I spend so much time on this problem but can not find why

It is so strange......

@RainbowRui
Copy link
Collaborator

Thanks for your analysis. We also need to study the reasons carefully.

@ForrestPi
Copy link

@NaNillll @RainbowRui @Juyong yeah the same problem , My version pytorch==1.11.
Have you solved the problem ?

@beanrac
Copy link

beanrac commented Dec 27, 2022

This issue can be resolved by using PyTorch 1.12 and later or setting:

torch.backends.cuda.matmul.allow_tf32 = False

TensorFloat-32(TF32) on Ampere devices
Starting in PyTorch 1.7, there is a new flag called allow_tf32. This flag defaults to True in PyTorch 1.7 to PyTorch 1.11, and False in PyTorch 1.12 and later. This flag controls whether PyTorch is allowed to use the TensorFloat32 (TF32) tensor cores, available on new NVIDIA GPUs since Ampere, internally to compute matmul (matrix multiplies and batched matrix multiplies) and convolutions.

TF32 tensor cores are designed to achieve better performance on matmul and convolutions on torch.float32 tensors by rounding input data to have 10 bits of mantissa, and accumulating results with FP32 precision, maintaining FP32 dynamic range.

@Vincent-ZHQ
Copy link

This issue can be resolved by using PyTorch 1.12 and later or setting:

torch.backends.cuda.matmul.allow_tf32 = False

TensorFloat-32(TF32) on Ampere devices
Starting in PyTorch 1.7, there is a new flag called allow_tf32. This flag defaults to True in PyTorch 1.7 to PyTorch 1.11, and False in PyTorch 1.12 and later. This flag controls whether PyTorch is allowed to use the TensorFloat32 (TF32) tensor cores, available on new NVIDIA GPUs since Ampere, internally to compute matmul (matrix multiplies and batched matrix multiplies) and convolutions.
TF32 tensor cores are designed to achieve better performance on matmul and convolutions on torch.float32 tensors by rounding input data to have 10 bits of mantissa, and accumulating results with FP32 precision, maintaining FP32 dynamic range.

It helps me a lot.
When I install a different torch version, I cannot reproduce the author's results with their examples. The generated landmarks do not match with the input images. When adding this setting in cariface.py, the loss will be very small and the generated landmarks can match with the input images.

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

No branches or pull requests

5 participants