• ubuntu 从零安装tf-serving环境和opencv


    参考官网:https://www.tensorflow.org/serving/setup

    首先是安装gprc:

    pip install grpcio  

    然后发现没有安装pip,报错:
    sudo: pip: command not found


    好吧,那就先跳过这个,直接执行下一条语句:
    sudo apt-get update && sudo apt-get install -y
            build-essential
            curl
            libcurl3-dev
            git
            libfreetype6-dev
            libpng12-dev
            libzmq3-dev
            pkg-config
            python-dev
            python-numpy
            python-pip
            software-properties-common
            swig
            zip
            zlib1g-dev

    ok以后,安装 serving api:
     pip install tensorflow-serving-api
    报错:
    Traceback (most recent call last):
      File "/usr/bin/pip", line 11, in <module>
        sys.exit(main())
      File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
        locale.setlocale(locale.LC_ALL, '')
      File "/usr/lib/python2.7/locale.py", line 581, in setlocale
        return _setlocale(category, locale)
    locale.Error: unsupported locale setting

    再尝试:pip install grpcio 还是报错:
    Traceback (most recent call last):
      File "/usr/bin/pip", line 11, in <module>
        sys.exit(main())
      File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
        locale.setlocale(locale.LC_ALL, '')
      File "/usr/lib/python2.7/locale.py", line 581, in setlocale
        return _setlocale(category, locale)
    locale.Error: unsupported locale setting

    网上查到解决方法:https://stackoverflow.com/questions/36394101/pip-install-locale-error-unsupported-locale-setting

    just run the following command:

    $ export LC_ALL=C

    Long answer-

    Here is my locale settings:

    $ locale
    LANG=en_US.UTF-8
    LANGUAGE=
    LC_CTYPE="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_COLLATE="C"
    LC_MONETARY="C"
    LC_MESSAGES="C"
    LC_PAPER="C"
    LC_NAME="C"
    LC_ADDRESS="C"
    LC_TELEPHONE="C"
    LC_MEASUREMENT="C"
    LC_IDENTIFICATION="C"
    LC_ALL=C
    怎么校验嫩?

    Python2.7

        $ uname -a
        Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6 (2015-11-09) x86_64 GNU/Linux
        $ python --version
        Python 2.7.9
        $ pip --version
        pip 8.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
        $ unset LC_ALL
        $ pip install grpcio
        Traceback (most recent call last):
          File "/usr/local/bin/pip", line 11, in <module>
            sys.exit(main())
          File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
            locale.setlocale(locale.LC_ALL, '')
          File "/usr/lib/python2.7/locale.py", line 579, in setlocale
            return _setlocale(category, locale)
        locale.Error: unsupported locale setting
        $ export LC_ALL=C
        $ pip install grpcio
    就可以了

    pip install tensorflow-serving-api ok,可以,继续,这个是作为client的用的


    接下来
    echo "deb [arch=amd64] http://storage.googleapis.com/tensorflow-serving-apt stable tensorflow-model-server tensorflow-model-server-universal" | sudo tee /etc/apt/sources.list.d/tensorflow-serving.list

    curl https://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg | sudo apt-key add -

    sudo apt-get update && sudo apt-get install tensorflow-model-server

    这样 model  serving 和client 就都ok 啦

    不过后面执行脚本中用到了opencv,所以这里也加下opencv的安装:

    执行 Python ****.py时,报错:

        import cv2
    ImportError: No module named cv2

    安装:  pip install python-opencv 报错:

    Collecting python-opencv
      Could not find a version that satisfies the requirement python-opencv (from versions: )
    No matching distribution found for python-opencv
    You are using pip version 8.1.1, however version 9.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.

    好吧,那就升级pip:

    pip install --upgrade pip    然后在执行上面的还是没用,那就换个方式安装opencv了:

    执行:

    sudo apt-get install Python-OpenCV  安装了一大堆东西,还是没用

    要放大招了: sudo apt-get install libopencv-dev

    虽然安装了,但是还是没有用,看来只能大大招了:

    sudo apt-get install python-opencv

    然后可以了。。。。。这是什么鬼!!!! 没发现倒数两个只是大小写问题吗!!!!!!!,我也是醉了。
















  • 相关阅读:
    MySQL8.0 不能使用group by解决方法
    xtrabackup备份恢复
    pycharm使用
    CMDB开发(三)
    Restful接口规范
    django-rest-framework框架(一)
    CMDB开发(二)
    CMDB开发(一)
    数据可视化之matplotlib模块
    数据分析之pyecharts v1版本
  • 原文地址:https://www.cnblogs.com/YouXiangLiThon/p/8043825.html
Copyright © 2020-2023  润新知