You have to call the backward pass before accessing .grad, otherwise it will be None:
model = nn.Linear(10, 2)
x = torch.randn(1, 10)
output = model(x)
output.mean().backward()
print(model.weight.grad)