Repository: tensorflow/addons

Issue:
Segmentation fault when using tfa.rotate in tf-nightly
**System information**
- OS Platform: Linux Ubuntu 18.04.3 LTS
- TensorFlow version: tf-nightly (2.2.0-dev20200310) installed with pip
- TensorFlow-Addons version: 0.8.3 (pip) and tfa-nightly (0.9.0-dev; pip)
- Python version: 3.6.9
- Is GPU used?: yes

**Describe the bug**
I currently have to use tf-nightly because of a separate issue. When I use tfa.rotate I get a segmentation fault. Behavior is the same with tfa 0.8.3 and tfa-nightly.

**Code to reproduce the issue**
```
import tensorflow as tf
import tensorflow_addons as tfa

img = tf.io.read_file(IMG_PATH)
img = tf.image.decode_png(img)
print(img.shape)
img = tfa.image.rotate(img, 90)
```
Output:     
> (128, 128, 3)
> Segmentation fault (core dumped)

I also tried `interpolation="BILINEAR"`. Problem is the same. 


Discussion:
Segfaults are normal when using tfa with tensorflow nightly. Tensorflow Addons is built against tensorflow 2.1.0 stable. Since the ABI is not stable from version from version to version, people get segfaults when using it with other tensorflow versions than the 2.1.0.

Can you install tensorflow 2.1.0 and tell us if the error still occurs?
Ah ok, thanks for your quick reply.
I can confirm that it works without issues with tensorflow 2.1.0.
I understand that the fact that we're targeting TF stable is not obvious, you're not the first person raising an issue like that. So there is a  problem on our side. 

We need to do a better job at checking the tensorflow version and tell users that something is wrong. 

Just leaving them with a segmentation is not good enough. I'll open a pull request for that. Sorry about the trouble.

Resolving patch:
diff --git a/tensorflow_addons/utils/ensure_tf_install.py b/tensorflow_addons/utils/ensure_tf_install.py
--- a/tensorflow_addons/utils/ensure_tf_install.py
+++ b/tensorflow_addons/utils/ensure_tf_install.py
@@ -17,27 +17,40 @@
 # Ensure TensorFlow is importable and its version is sufficiently recent. This
 # needs to happen before anything else, since the imports below will try to
 # import tensorflow, too.
+
+from distutils.version import LooseVersion
+import warnings
+
+import tensorflow as tf
+
+
+warning_template = """
+This version of TensorFlow Addons requires TensorFlow {required}.
+Detected an installation of version {present}.
+
+While some functions might work, TensorFlow Addons was not tested
+with this TensorFlow version. Also custom ops were not compiled
+against this version of TensorFlow. If you use custom ops,
+you might get errors (segmentation faults for example).
+
+It might help you to fallback to pure Python ops with
+TF_ADDONS_PY_OPS . To do that, see
+https://github.com/tensorflow/addons#gpucpu-custom-ops
+
+If you encounter errors, do *not* file bugs in GitHub because
+the version of TensorFlow you are using is not supported.
+"""
+
+
 def _ensure_tf_install():
-    """Attempt to import tensorflow, and ensure its version is sufficient.
-    Raises:
-      ImportError: if either tensorflow is not importable or its version is
-      inadequate.
+    """Warn the user if the version of TensorFlow used is not supported.
     """
-    import tensorflow as tf
-    import distutils.version
 
-    #
     # Update this whenever we need to depend on a newer TensorFlow release.
-    #
-    required_tensorflow_version = "2.1.0"
-
-    if distutils.version.LooseVersion(tf.__version__) < distutils.version.LooseVersion(
-        required_tensorflow_version
-    ):
-        raise ImportError(
-            "This version of TensorFlow Addons requires TensorFlow "
-            "version >= {required}; Detected an installation of version "
-            "{present}. Please upgrade TensorFlow to proceed.".format(
-                required=required_tensorflow_version, present=tf.__version__
-            )
+    required_tf_version = "2.1.0"
+
+    if LooseVersion(tf.__version__) != LooseVersion(required_tf_version):
+        message = warning_template.format(
+            required=required_tf_version, present=tf.__version__
         )
+        warnings.warn(message, UserWarning)


Test patch: