There seems to be a bug in AdaptiveAvgPool3d on cuda.
Can someone confirm this with a different computer/PyTorch version?
The bug occurs when trying to compute autograd.grad of AdaptiveAvgPool3d. 1d and 2d works fine. My torch.__version__: ‘1.8.1+cu102’
To reproduce you can run the following code:
import torch
from torch import Tensor
from torch.nn import AdaptiveAvgPool3d

module: AdaptiveAvgPool3d = AdaptiveAvgPool3d(output_size=2)
inputs: Tensor = torch.rand(size=(1, 1, 2, 2, 4))
inputs.requires_grad = True
output_cpu: Tensor = module(inputs)
mat: Tensor = torch.rand_like(output_cpu)
derivative_cpu_torch: Tensor = torch.autograd.grad(output_cpu, inputs, mat)[0]

module.to(device=1)
inputs = inputs.to(device="cuda")
mat = mat.to(device="cuda")
output_cuda: Tensor = module(inputs)
derivative_cuda_torch: Tensor = torch.autograd.grad(output_cuda, inputs, mat)[0]

print("Outputs identical?", torch.allclose(output_cpu, output_cuda.to(device="cpu")))
print(
    "Torch derivatives (cuda+cpu) match?",
    torch.allclose(derivative_cpu_torch, derivative_cuda_torch.to(device="cpu")),
)
print("cpu derivative torch:", derivative_cpu_torch)
print("cuda derivative torch:", derivative_cuda_torch)

Has the following output for me (no fixed seed):
Outputs identical? True
Torch derivatives (cuda+cpu) match? False
cpu derivative torch: tensor([[[[[0.3119, 0.3119, 0.3913, 0.3913],
           [0.3091, 0.3091, 0.0067, 0.0067]],

          [[0.1353, 0.1353, 0.1326, 0.1326],
           [0.2254, 0.2254, 0.4297, 0.4297]]]]])
cuda derivative torch: tensor([[[[[0.3119, 0.3119, 0.3913, 0.3913],
           [0.1353, 0.1353, 0.1326, 0.1326]],

          [[0.1353, 0.1353, 0.1326, 0.1326],
           [0.0000, 0.0000, 0.0000, 0.0000]]]]], device='cuda:0')