Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example not working (anymore?) #2

Open
cg-laser opened this issue Jan 16, 2020 · 2 comments
Open

Example not working (anymore?) #2

cg-laser opened this issue Jan 16, 2020 · 2 comments

Comments

@cg-laser
Copy link

I can't get this example to work. I'm not sure if this is because of inconsistencies with newer dependencies but everything I tried was unsuccessful. This is what I tried so far:

The first error I get when following the example step by step is

Traceback (most recent call last):
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/bin/utensor-cli", line 5, in <module>
    from utensor_cgen.cli import cli
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/cli.py", line 8, in <module>
    from .utils import NArgsParam
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/utils.py", line 11, in <module>
    from tensorflow.tools.graph_transforms import TransformGraph
ImportError: No module named graph_transforms

which is because tensorflow 2.1.0 was installed by pip install utensor_cgen==0.3.3.dev2

So I downgraded tensorflow to 1.13.2 but then I just run into the next error:

utensor-cli convert cifar10_cnn.pb --output-nodes=fully_connect_2/logits

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

Traceback (most recent call last):
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/bin/utensor-cli", line 8, in <module>
    sys.exit(cli())
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/cli.py", line 84, in convert_graph
    generator.generate(model_path)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/backend/code_generator.py", line 49, in generate
    parser_cls = FrontendSelector.select_parser(ext)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/frontend/__init__.py", line 26, in select_parser
    cls._setup()
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/frontend/__init__.py", line 46, in _setup
    importlib.import_module(mod_name)
  File "/Users/cglaser/.pyenv/versions/2.7.15/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/utensor_cgen/frontend/onnx.py", line 2, in <module>
    from onnx_tf.backend import prepare
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/onnx_tf/__init__.py", line 1, in <module>
    from . import backend
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/onnx_tf/backend.py", line 29, in <module>
    from onnx_tf.common.handler_helper import get_all_backend_handlers
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/onnx_tf/common/handler_helper.py", line 5, in <module>
    from onnx_tf.handlers.backend import *  # noqa
  File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/onnx_tf/handlers/backend/scatter_nd.py", line 8, in <module>
    @tf_func(tf.tensor_scatter_nd_update)
AttributeError: 'module' object has no attribute 'tensor_scatter_nd_update'
make: *** [models/cifar10_cnn.cpp] Error 1

I get the same error also for python 3.7.3.

I then tried upgrading utensor_cgen to the latest release, but this also crashes maybe because it is not python2.7 compatible anymore?

pip install utensor_cgen --upgrade
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting utensor_cgen
  Using cached https://files.pythonhosted.org/packages/a2/a3/d6db368011e481e38dce7b209d3818942b5dc157ef8b528b8cf3bf414d64/utensor_cgen-0.4.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/setup.py'"'"'; __file__='"'"'/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/pip-egg-info
         cwd: /private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/
    Complete output (24 lines):
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/setup.py", line 79, in <module>
        "Topic :: Utilities"
      File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/Users/cglaser/.pyenv/versions/2.7.15/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/setuptools/dist.py", line 448, in __init__
        k: v for k, v in attrs.items()
      File "/Users/cglaser/.pyenv/versions/2.7.15/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/setuptools/dist.py", line 740, in finalize_options
        ep.load()(self)
      File "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial/.venv/lib/python2.7/site-packages/setuptools/dist.py", line 747, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File "/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/.eggs/better_setuptools_git_version-1.0.5-py2.7.egg/better_setuptools_git_version.py", line 82, in validate_version_config
        dist.metadata.version = get_version(template, starting_version)
      File "/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/.eggs/better_setuptools_git_version-1.0.5-py2.7.egg/better_setuptools_git_version.py", line 52, in get_version
        tag = get_tag()
      File "/private/var/folders/bt/vcs5g33x3mn05hx6tn023ssc0000gn/T/pip-install-OxAhcH/utensor-cgen/.eggs/better_setuptools_git_version-1.0.5-py2.7.egg/better_setuptools_git_version.py", line 9, in get_tag
        return subprocess.getoutput("git tag --sort=version:refname --merged | tail -n1")
    AttributeError: 'module' object has no attribute 'getoutput'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

With python3 I upgraded utensor_cgen to the latest version which also downgraded tensorflow to 1.13.1
Successfully installed graphviz-0.13.2 onnx-tf-1.2.1 tensorflow-1.13.1 toml-0.10.0 utensor-cgen-0.4.2

This allows to execute utensor-cli convert cifar10_cnn.pb --output-nodes fully_connect_2/logits without errors.

However, the compilation of the mbed code then crashes with

mbed compile -m auto -t GCC_ARM --profile=uTensor/build_profile/release.json -f
[mbed] Working path "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3" (program)
[mbed] WARNING: Could not find mbed program in current path "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3".
       You can fix this by calling "mbed new ." in the root of your program.
---
[mbed] Detected "K64F" connected to "/Volumes/DAPLINK" and using com port "/dev/tty.usbmodem1422"
[Warning] @,: Compiler version mismatch: Have 9.2.1; expected version >= 6.0.0 and < 7.0.0
Building project simple_cnn_tutorial_p3 (K64F, GCC_ARM)
Scan: simple_cnn_tutorial_p3
...
Compile [ 85.2%]: mbed_rtc_time.cpp
[Error] mbed_rtc_time.cpp@89,22: invalid use of incomplete type 'const struct timeval'
[Error] mbed_rtc_time.cpp@110,7: invalid use of incomplete type 'struct timeval'
[Error] mbed_rtc_time.cpp@111,7: invalid use of incomplete type 'struct timeval'
[Error] mbed_rtc_time.cpp@124,20: aggregate 'timeval tv' has incomplete type and cannot be defined
[Error] mbed_rtc_time.cpp@137,26: variable 'const timeval tv' has initializer but incomplete type
[ERROR] '_queue.SimpleQueue' object has no attribute 'queue'
[mbed] ERROR: "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3/.venv/bin/python" returned error.
       Code: 1
       Path: "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3"
       Command: "/Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3/.venv/bin/python -u /Users/cglaser/work/ARIANNA/analysis/2019deeplearning/classification/uTensor_examples/simple_cnn_tutorial_p3/mbed-os/tools/make.py -t GCC_ARM -m K64F --profile uTensor/build_profile/release.json --source . --build ./BUILD/K64F/GCC_ARM-RELEASE"
       Tip: You could retry the last command with "-v" flag for verbose output
---
make: *** [compile] Error 255

Maybe this is because my compiler version is too high? [Warning] @,: Compiler version mismatch: Have 9.2.1; expected version >= 6.0.0 and < 7.0.0
So I downgraded my GCC_ARM toolchain to 6.3.1 but I still get the same error.

Any help would be greatly appreciated!

@finnss
Copy link

finnss commented Jan 22, 2020

I'm having a similar issue and would love to see an answer!

As a side note, how did you downgrade your toolchain? I've downloaded GCC ARM None Eabi v9.2.1, and I tried pointing to it in several ways.

  • mbed config -G GCC_ARM_PATH ~/Documents/skole/master_thesis/arm_mbed/gcc-arm
  • The same without -G.
  • The same but using MBED_GCC_ARM_PATH, I'm still not sure which is used
  • The same, but pointing to the /bin folder of that path
  • Removing all mbed config and choosing the parameters through environment variables

None of these attempts seemed to change anything, though. I'm getting [Warning] @,: Compiler version mismatch: Have 6.3.1; expected version >= 9.0.0 and < 10.0.0 no matter what I do. Also, isn't it weird that it is requiring a version between 9 and 10? Most threads I've seen say only version 6 is supported.

@finnss
Copy link

finnss commented Jan 22, 2020

For the record, I'm working on a different uTensor example, the one from this guide: https://www.hackster.io/news/simple-neural-network-on-mcus-a7cbd3dc108c

I'm guessing the underlying issue is the same though, and I didn't have any better luck trying this simple_cnn_tutorial. My error message is slightly different:

mbed compile --target NRF52_DK --toolchain GCC_ARM -f                                                                 finn@Finns-MacBook-Pro
[mbed] Working path "/Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor" (library)
[mbed] Program path "/Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor"
[Warning] @,: Compiler version mismatch: Have 6.3.1; expected version >= 9.0.0 and < 10.0.0
Building project my_uTensor (NRF52_DK, GCC_ARM)
Scan: my_uTensor
Compile [  0.3%]: ESP8266.cpp
[Error] ctime@62,11: '::tm' has not been declared
[Error] ctime@64,11: '::clock' has not been declared
[Error] ctime@65,11: '::difftime' has not been declared
[Error] ctime@66,11: '::mktime' has not been declared
[Error] ctime@67,11: '::time' has not been declared
[Error] ctime@68,11: '::asctime' has not been declared
[Error] ctime@69,11: '::ctime' has not been declared
[Error] ctime@70,11: '::gmtime' has not been declared
[Error] ctime@71,11: '::localtime' has not been declared
[Error] ctime@72,11: '::strftime' has not been declared
[Error] time.h@29,32: 'tm' was not declared in this scope
[Error] time.h@29,36: expected primary-expression before 'const'
[Error] time.h@34,33: variable or field 'LocalTime' declared void
[Error] time.h@34,33: 'tm' was not declared in this scope
[Error] time.h@34,37: 't' was not declared in this scope
[Error] time.h@34,52: expected primary-expression before 'time'
[Error] time.h@39,30: variable or field 'GMTime' declared void
[Error] time.h@39,30: 'tm' was not declared in this scope
[Error] time.h@39,34: 't' was not declared in this scope
[Error] time.h@39,49: expected primary-expression before 'time'
[ERROR] In file included from ./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:19:0,
                 from ./mbed-os/platform/mbed_retarget.h:80,
                 from ./mbed-os/platform/platform.h:26,
                 from ./mbed-os/drivers/UARTSerial.h:21,
                 from ./mbed-os/components/wifi/esp8266-driver/ESP8266/ESP8266.h:23,
                 from ./mbed-os/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp:26:
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:62:11: error: '::tm' has not been declared
   using ::tm;
           ^~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:64:11: error: '::clock' has not been declared
   using ::clock;
           ^~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:65:11: error: '::difftime' has not been declared
   using ::difftime;
           ^~~~~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:66:11: error: '::mktime' has not been declared
   using ::mktime;
           ^~~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:67:11: error: '::time' has not been declared
   using ::time;
           ^~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:68:11: error: '::asctime' has not been declared
   using ::asctime;
           ^~~~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:69:11: error: '::ctime' has not been declared
   using ::ctime;
           ^~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:70:11: error: '::gmtime' has not been declared
   using ::gmtime;
           ^~~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:71:11: error: '::localtime' has not been declared
   using ::localtime;
           ^~~~~~~~~
/usr/local/Cellar/arm-gcc-bin/6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/ctime:72:11: error: '::strftime' has not been declared
   using ::strftime;
           ^~~~~~~~
In file included from ./mbed-os/platform/mbed_retarget.h:80:0,
                 from ./mbed-os/platform/platform.h:26,
                 from ./mbed-os/drivers/UARTSerial.h:21,
                 from ./mbed-os/components/wifi/esp8266-driver/ESP8266/ESP8266.h:23,
                 from ./mbed-os/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp:26:
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:29:32: error: 'tm' was not declared in this scope
     AWS_CORE_API time_t TimeGM(tm* const t);
                                ^~
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:29:36: error: expected primary-expression before 'const'
     AWS_CORE_API time_t TimeGM(tm* const t);
                                    ^~~~~
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:34:33: error: variable or field 'LocalTime' declared void
     AWS_CORE_API void LocalTime(tm* t, std::time_t time);
                                 ^~
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:34:33: error: 'tm' was not declared in this scope
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:34:37: error: 't' was not declared in this scope
     AWS_CORE_API void LocalTime(tm* t, std::time_t time);
                                     ^
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:34:52: error: expected primary-expression before 'time'
     AWS_CORE_API void LocalTime(tm* t, std::time_t time);
                                                    ^~~~
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:39:30: error: variable or field 'GMTime' declared void
     AWS_CORE_API void GMTime(tm* t, std::time_t time);
                              ^~
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:39:30: error: 'tm' was not declared in this scope
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:39:34: error: 't' was not declared in this scope
     AWS_CORE_API void GMTime(tm* t, std::time_t time);
                                  ^
./venv/lib/python3.7/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/platform/time.h:39:49: error: expected primary-expression before 'time'
     AWS_CORE_API void GMTime(tm* t, std::time_t time);
                                                 ^~~~

[mbed] ERROR: "/Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor/venv/bin/python3" returned error.
       Code: 1
       Path: "/Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor"
       Command: "/Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor/venv/bin/python3 -u /Users/finn/Documents/skole/master_thesis/arm_mbed/my_uTensor/mbed-os/tools/make.py -t GCC_ARM -m NRF52_DK --source . --build ./BUILD/NRF52_DK/GCC_ARM"
       Tip: You could retry the last command with "-v" flag for verbose output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants