Keras/Tensorflow Model fails "ImportError: No module named tensorflow"

Solved!
Bogdan
Level 1
Keras/Tensorflow Model fails "ImportError: No module named tensorflow"

Hi there guys!



I just installed Dataiku on MacOS (so gpu processing is not supported).



Trying to build a Deep learning model with keras and tensorflow, got an import error for tensorflow (using the default configuration/script).



Is there something I'm doing wrong?



Your help would be much appreciated.



The error:




[2019-05-23 15:57:36,358] [65612/MainThread] [INFO] [root] END - Fitting preprocessors
[2019-05-23 15:57:36,358] [65612/MainThread] [INFO] [root] START - Preprocessing train set
[2019-05-23 15:57:36,358] [65612/MainThread] [INFO] [root] END - Preprocessing train set
[2019-05-23 15:57:36,358] [65612/MainThread] [INFO] [root] START - Preprocessing test set
[2019-05-23 15:57:36,363] [65612/MainThread] [INFO] [root] END - Preprocessing test set
[2019-05-23 15:57:36,365] [65612/MainThread] [INFO] [root] START - Fitting model
[2019-05-23 15:57:36,367] [65612/MainThread] [INFO] [root] END - Fitting model
Traceback (most recent call last):
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/server.py", line 47, in serve
ret = api_command(arg)
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/dkuapi.py", line 45, in aux
return api(**kwargs)
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/commands.py", line 419, in train_prediction_keras
pipeline.generated_features_mapping)
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/prediction_entrypoints.py", line 350, in prediction_train_model_keras
generated_features_mapping)
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/deep_learning/keras_support.py", line 26, in get_keras_model
[2019/05/23-15:57:36.367] [MRT-1323] [INFO] [dku.block.link.interaction] - Check result for nullity exceptionIfNull=true result=null
from dataiku.doctor.deep_learning import gpu
File "/Applications/DataScienceStudio.app/Contents/Resources/kit/python/dataiku/doctor/deep_learning/gpu.py", line 5, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
[2019/05/23-15:57:36.462] [KNL-python-single-command-kernel-monitor-1327] [INFO] [dku.kernels] - Process done with code 0
[2019/05/23-15:57:36.465] [KNL-python-single-command-kernel-monitor-1327] [INFO] [dip.tickets] - Destroying API ticket for analysis-ml-ENERGY_PREDICTION_V1-kbMnWwD on behalf of admin
[2019/05/23-15:57:36.466] [MRT-1323] [INFO] [dku.kernels] - Getting kernel tail
[2019/05/23-15:57:36.467] [MRT-1323] [INFO] [dku.kernels] - Trying to enrich exception: com.dataiku.dip.io.SocketBlockLinkKernelException: Failed to train : <type 'exceptions.ImportError'> : No module named tensorflow from kernel com.dataiku.dip.analysis.coreservices.AnalysisMLKernel@6a50edbb process=null pid=?? retcode=0
[2019/05/23-15:57:36.467] [MRT-1323] [WARN] [dku.analysis.ml.python] - Training failed
com.dataiku.dip.io.SocketBlockLinkKernelException: Failed to train : <type 'exceptions.ImportError'> : No module named tensorflow
at com.dataiku.dip.io.SocketBlockLinkInteraction.throwExceptionFromPython(SocketBlockLinkInteraction.java:302)
at com.dataiku.dip.io.SocketBlockLinkInteraction$AsyncResult.checkException(SocketBlockLinkInteraction.java:215)
at com.dataiku.dip.io.SocketBlockLinkInteraction$AsyncResult.get(SocketBlockLinkInteraction.java:190)
at com.dataiku.dip.io.SingleCommandKernelLink$1.call(SingleCommandKernelLink.java:208)
at com.dataiku.dip.analysis.ml.prediction.PredictionTrainAdditionalThread.process(PredictionTrainAdditionalThread.java:75)
at com.dataiku.dip.analysis.ml.shared.PRNSTrainThread.run(PRNSTrainThread.java:130)


 

0 Kudos
1 Solution
Nicolas_Servel
Dataiker

Hello Bogdan,



It seems that you did not install the proper code environment to be able to run deep learning models.



Dataiku DSS is not shipped directly with Keras and Tensorflow, but offers the possibility to easily install them, and then use them in the visual Machine learning, to run deep learning models.



The steps to setup the appropriate code environment are detailed in the "Prerequisites" part of this tutorial:



https://www.dataiku.com/learn/guide/visual/machine-learning/deep-learning-first.html



Don't hesitate to come back to us if you have troubles installing the environment.



 



Best regards,



Nicolas Servel

View solution in original post

0 Kudos
4 Replies
Nicolas_Servel
Dataiker

Hello Bogdan,



It seems that you did not install the proper code environment to be able to run deep learning models.



Dataiku DSS is not shipped directly with Keras and Tensorflow, but offers the possibility to easily install them, and then use them in the visual Machine learning, to run deep learning models.



The steps to setup the appropriate code environment are detailed in the "Prerequisites" part of this tutorial:



https://www.dataiku.com/learn/guide/visual/machine-learning/deep-learning-first.html



Don't hesitate to come back to us if you have troubles installing the environment.



 



Best regards,



Nicolas Servel

0 Kudos
Bogdan
Level 1
Author
Thank you!
Installed the code env and got model to work.
0 Kudos
sunrise100
Level 2

Hello, for the error AttributeError: module tensorflow has no attribute placeholder



you may like to check this link.



https://botbark.com/2019/12/18/attributeerror-module-tensorflow-has-no-attribute-placeholder-tensorf...

0 Kudos
lchunleo
Level 2

i have similar issue. i read the link and prepare my env and ensuring keras and tensorflow and scipy, scikit, xgs, are all installed and verified. but i still unable to get it working when i invoked commands to do "import keras or import tensorflow"

i had chosen visual learning of keras, tensorflow with gpu for cuda 9. I also confirmed i have the gpu as i able to access my gpu from my own terminal and run deep learning programs on it.

 

i am using cuda 10 on my machine

 

Using TensorFlow backend.
 
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~/Downloads/DATA_DIR/code-envs/python/python36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
     57 
---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
     59   from tensorflow.python.pywrap_tensorflow_internal import __version__

~/Downloads/DATA_DIR/code-envs/python/python36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper
0 Kudos

Labels

?
Labels (1)
A banner prompting to get Dataiku