Tanh does not work under gpu

I’m trying to evaluate the hyperbolic tangent of a Tensorflow vector. The operation works fine under TensorFlow but tensorflow-gpu provides the following error:

 I_so = (0.5 * (a_so - tau_a) * (1 + tf.tanh((U - b_so) / c_so)) +
  File "/home/cc14/Software/anaconda3/envs/tf-gpu/lib/python3.8/site-packages/tensorflow/python/ops/gen_math_ops.py", line 10529, in tanh
    _ops.raise_from_not_ok_status(e, name)
  File "/home/cc14/Software/anaconda3/envs/tf-gpu/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 6862, in raise_from_not_ok_status
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InternalError: Failed to load in-memory CUBIN: CUDA_ERROR_NO_BINARY_FOR_GPU: no kernel image is available for execution on the device [Op:Tanh]

what did generate it? Is there a way to use tf.tanh under GPU?

thanks,

Cesare

Hi Cesare!

I’m able to use tf.tanh on the GPU, see below. Here are two links that have helped me in the past with these sorts of issues:

Installation using pip
GPU guide

Pritam

[ins] In [6]: tf.config.list_physical_devices('GPU')                                                                                                                                                       
Out[6]: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]                                                                                                                                 
                                                                                                                                                                                                           
[nav] In [7]: x = tf.constant([-float("inf"), -5, -0.5, 1, 1.2, 2, 3, float("inf")])                                                                                                                       
                                                                                                                                                                                                           
[nav] In [8]: tf.tanh(x)                                                                                                                                                                                   
Out[8]:                                                                                                                                                                                                    
<tf.Tensor: shape=(8,), dtype=float32, numpy=                                                                                                                                                              
array([-1.        , -0.99990916, -0.46211717,  0.7615942 ,  0.8336546 ,                                                                                                                                    
        0.9640276 ,  0.9950547 ,  1.        ], dtype=float32)>