Forums - Import Error : tf.contrib

2 posts / 0 new
Last post
Import Error : tf.contrib
jerry
Join Date: 19 Nov 19
Posts: 4
Posted: Mon, 2020-05-25 09:19

https://developer.qualcomm.com/docs/snpe/tutorial_setup.html

In following the above tutorial, I come to this point :

usage: $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py [-h] -a ASSETS_DIR [-d] [-r RUNTIME] [-u]
 
The process returns "ImportError: No module named 'tensorflow.contrib". After scouting for some reolsutions , it seems that tf.contrib is not supported in Tensorflow 2.x .
 
I am using Tensforflow 2.2.0 - gpu , Cuda 10.2 and cuDNN 7.6.5. It took a while to set eveything up and now I am not going to downgrade to Tensorflow 1, what is the solution to convert SNPE-TENSORFLOW-DLC using Tensorflow 2.x.
 
Thanks
 
Partial screendump :
INFO: Creating image list data files
/home/jerry/snpe-root/models/inception_v3/data/cropped/raw_list.txt created listing 4 files.
/home/jerry/snpe-root/models/inception_v3/data/target_raw_list.txt created listing 4 files.
INFO: Converting inception_v3_2016_08_28_frozen.pb to SNPE DLC format
['snpe-tensorflow-to-dlc', '--input_network', '/home/jerry/snpe-root/models/inception_v3/tensorflow/inception_v3_2016_08_28_frozen.pb', '--input_dim', 'input', '1,299,299,3', '--out_node', 'InceptionV3/Predictions/Reshape_1', '--output_path', '/home/jerry/snpe-root/models/inception_v3/dlc/inception_v3.dlc', '--allow_unconsumed_nodes']
Traceback (most recent call last):
  File "/home/jerry/snpe-root/bin/x86_64-linux-clang/snpe-tensorflow-to-dlc", line 24, in <module>
    from snpe.converters.tensorflow.tf_to_ir import TFConverter
  File "/home/jerry/snpe-root/lib/python/snpe/converters/tensorflow/tf_to_ir.py", line 19, in <module>
    from snpe.converters.tensorflow.loader import ModelLoader
  File "/home/jerry/snpe-root/lib/python/snpe/converters/tensorflow/loader.py", line 14, in <module>
    import tensorflow.contrib
ImportError: No module named 'tensorflow.contrib'
INFO: Setup inception_v3 completed.
 
  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Mon, 2020-05-25 21:22

Hi Jerry,

We run the latest NPE 1.38 with the Ubuntu 16 having TF 1.13.1 without any issues using python3.5
Run the following command to install python3.5

$  sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.5jerry

TF2 version is not fully supported yet.  So, it is suggested to use the TF 1.13.1 or TF 1.15
We run the latest NPE 1.38 with the Ubuntu 16 having TF 1.13.1 without any issues.


$ sudo python3.5 -m pip install tensorflow==1.13.1  or  $ sudo python3.5 -m pip install tensorflow==1.15

post-installation, possibly you can find the TensorFlow in the below-mentioned path.

/usr/local/lib/python3.5/dist-packages/tensorflow

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.