Repository: keras-team/autokeras

Issue:
installation issue o
**My environment is a Jetson Xavier** 
Jetpack 4.2 
Ubuntu 18.04
python version is 3.6.8
relevant pip.list
dask (2.8.0)
dask-glm (0.2.0)
dask-ml (1.1.1)
Keras (2.3.1)
Keras-Applications (1.0.8)
Keras-Preprocessing (1.1.0)
numba (0.46.0)
numpy (1.17.4)
packaging (19.2)
pandas (0.25.3)
pandas-flavor (0.2.0)
pip (19.3.1)
scikit-learn (0.21.3)
scikit-MDR (0.4.4)
scipy (1.3.2)
tensorboard (1.14.0)
tensorflow-estimator (1.14.0)
**tensorflow-gpu (1.14.0+nv19.10)**

**error messages**
pip install git+git://github.com/keras-team/autokeras@master#egg=autokeras
Collecting autokeras
Cloning git://github.com/keras-team/autokeras (to revision master) to /tmp/pip-install-du3y560o/autokeras
Running command git clone -q git://github.com/keras-team/autokeras /tmp/pip-install-du3y560o/autokeras
ERROR: Could not find a version that satisfies the requirement tensorflow (from autokeras) (from versions: none)
ERROR: No matching distribution found for tensorflow (from autokeras)
**Then I tried**
pip install autokeras
Collecting autokeras
  Downloading https://files.pythonhosted.org/packages/c2/32/de74bf6afd09925980340355a05aa6a19e7378ed91dac09e76a487bd136d/autokeras-0.4.0.tar.gz (67kB)
     |████████████████████████████████| 71kB 3.8MB/s 
Collecting scipy==1.2.0
  Downloading https://files.pythonhosted.org/packages/ea/c8/c296904f2c852c5c129962e6ca4ba467116b08cd5b54b7180b2e77fe06b2/scipy-1.2.0.tar.gz (23.3MB)
     |████████████████████████████████| 23.3MB 12.6MB/s 
ERROR: Could not find a version that satisfies the requirement tensorflow==1.13.1 (from autokeras) (from versions: none)
**ERROR: No matching distribution found for tensorflow==1.13.1 (from autokeras)**

I have tried downgrading to tensorflow-gpu==1.13.1, but get the same error message
ERROR: No matching distribution found for tensorflow==1.13.1 (from autokeras)

My hunch is autokeras does not include tensorflow-gpu, thoughts on how to fix this?

thanks in advance for your assistance


Discussion:
Same issue here
A quick fix is to install it without the dependencies. `pip install --no-deps git+git://github.com/keras-team/autokeras`. 

The long term fix is to remove tensorflow from the setup.py, otherwise it's going to try to install the cpu version of tensorflow everytime. I would consider that a bug. 

See https://github.com/keras-team/keras-tuner/issues/168 which has the same problem.

Resolving patch:
diff --git a/autokeras/__init__.py b/autokeras/__init__.py
--- a/autokeras/__init__.py
+++ b/autokeras/__init__.py
@@ -35,3 +35,6 @@
 from autokeras.task import StructuredDataRegressor
 from autokeras.task import TextClassifier
 from autokeras.task import TextRegressor
+
+from .utils import check_tf_version
+check_tf_version()
diff --git a/autokeras/utils.py b/autokeras/utils.py
--- a/autokeras/utils.py
+++ b/autokeras/utils.py
@@ -1,5 +1,6 @@
 import pickle
 import re
+from packaging.version import parse
 
 import numpy as np
 import tensorflow as tf
@@ -127,3 +128,16 @@ def to_type_key(dictionary, convert_func):
     """
     return {convert_func(key): value
             for key, value in dictionary.items()}
+
+
+def check_tf_version():
+    if parse(tf.__version__) < parse('2.0.0'):
+        raise ImportError(
+            f'The Tensorflow package version needs to be at least v2.0.0 \n'
+            f'for AutoKeras to run. Currently, your TensorFlow version is \n'
+            f'v{tf.__version__}. Please upgrade with \n'
+            f'`$ pip install --upgrade tensorflow` -> GPU version \n'
+            f'or \n'
+            f'`$ pip install --upgrade tensorflow-cpu` -> CPU version. \n'
+            f'You can use `pip freeze` to check afterwards that everything is ok.'
+        )
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,8 +18,9 @@
     url='http://autokeras.com',
     download_url='https://github.com/keras-team/autokeras/archive/1.0.0a0.tar.gz',
     keywords=['AutoML', 'keras'],
+    # TODO: Do not install tensorflow if tensorflow-gpu is installed.
     install_requires=[
-        'tensorflow>=2.0.0',
+        'packaging',
         'keras-tuner>=1.0.0',
         'scikit-learn',
         'numpy',


Test patch: