-
Notifications
You must be signed in to change notification settings - Fork 74.8k
Open
Labels
Description
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
2.20.0-dev20250715
Custom code
Yes
OS platform and distribution
Linux Ubuntu 20.04
Mobile device
No response
Python version
3.12
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
Running tf.nn.local_response_normalization
on CPU with a negative beta
provides different results from PyTorch
with the same arguments. On GPU, the Tensorflow
version faces an error InvalidArgumentError: {{function_node __wrapped__LRN_device_/job:localhost/replica:0/task:0/device:GPU:0}} cuDNN requires beta >= 0.01, got: -1 [Op:LRN]
, while the PyTorch
version does not throw any such errors in the CUDA version.
Reproduced locally with nightly, also with 2.19.0
on colab.
Standalone code to reproduce the issue
import tensorflow as tf
import torch
print(tf.__version__) # 2.20.0-dev20250715
print(torch.__version__) # 2.7.1+cu126
a = tf.random.uniform(shape=(1, 1, 3, 1), minval=0, maxval=1, dtype=tf.float32, seed=100)
depth_radius = 5
alpha = 10
beta = -1
output_torch_cpu = torch.nn.functional.local_response_norm(torch.tensor(a.numpy()), size=depth_radius, alpha=alpha, beta=beta)
print("\nTorch output [cpu]:", output_torch_cpu)
'''
Torch output [cpu]: tensor([[[[2.7409],
[0.6304],
[0.7823]]]])
'''
output_torch_gpu = torch.nn.functional.local_response_norm(torch.tensor(a.numpy()).cuda(), size=depth_radius, alpha=alpha, beta=beta)
print("\nTorch output [gpu]:", output_torch_gpu)
'''
Torch output [gpu]: tensor([[[[2.7409],
[0.6304],
[0.7823]]]], device='cuda:0')
'''
with tf.device('/cpu:0'):
output_cpu = tf.nn.local_response_normalization(a, depth_radius=depth_radius, alpha=alpha, beta=beta)
print("\nTensorflow output [cpu]:", output_cpu)
'''
Tensorflow output [cpu]: tf.Tensor(
[[[[9.857574 ]
[1.3554668]
[1.8604573]]]], shape=(1, 1, 3, 1), dtype=float32)
'''
with tf.device('/gpu:0'):
output_gpu = tf.nn.local_response_normalization(a, depth_radius=depth_radius, alpha=alpha, beta=beta)
print("\nTensorflow output [gpu]:", output_gpu)
# InvalidArgumentError: {{function_node __wrapped__LRN_device_/job:localhost/replica:0/task:0/device:GPU:0}} cuDNN requires beta >= 0.01, got: -1 [Op:LRN]
Relevant log output
2.20.0-dev20250715
2.7.1+cu126
Torch output [cpu]: tensor([[[[2.7409],
[0.6304],
[0.7823]]]])
Torch output [gpu]: tensor([[[[2.7409],
[0.6304],
[0.7823]]]], device='cuda:0')
Tensorflow output [cpu]: tf.Tensor(
[[[[9.857574 ]
[1.3554668]
[1.8604573]]]], shape=(1, 1, 3, 1), dtype=float32)
2025-07-17 04:15:14.928312: I tensorflow/core/framework/local_rendezvous.cc:407] Local rendezvous is aborting with status: INVALID_ARGUMENT: cuDNN requires beta >= 0.01, got: -1
Traceback (most recent call last):
File ".../bug_reports/tf/test.py", line 62, in <module>
output_gpu = tf.nn.local_response_normalization(a, depth_radius=depth_radius, alpha=alpha, beta=beta)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../venv/lib/python3.12/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 5854, in lrn
return lrn_eager_fallback(
^^^^^^^^^^^^^^^^^^^
File ".../venv/lib/python3.12/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 5929, in lrn_eager_fallback
_result = _execute.execute(b"LRN", 1, inputs=_inputs_flat, attrs=_attrs,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../venv/lib/python3.12/site-packages/tensorflow/python/eager/execute.py", line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__LRN_device_/job:localhost/replica:0/task:0/device:GPU:0}} cuDNN requires beta >= 0.01, got: -1 [Op:LRN]