在Ubuntu 18.04.4 LTS虚拟机中安装TensorFlow for Visual Studio Code C ++项目时出现问题

时间:2020-07-13 18:41:54

标签: c++ tensorflow installation visual-studio-code ubuntu-18.04

我正在为Udacity C ++在线课程做一个顶峰项目。我可以在向蛇形计算机游戏添加功能或创建自己的项目之间进行选择。我正在寻找人工智能方面的工作,因此我决定创建自己的项目,并使用TensorFlow在Visual Studio Code中为猫狗图像分类器创建卷积神经网络。在TensorFlow安装期间出现错误,并且我不知道如何为TensorFlow op.h和shape_inference.h使用#include路径。

这是GitHub项目链接:https://github.com/ProfHariSeldon/CppND-Capstone-Hello-World

我尝试按照https://www.tensorflow.org/install中的说明在Ubuntu 18.04.4 LTS虚拟机中安装TensorFlow:

sudo apt install python-pip
pip install --upgrade pip
pip install tensorflow

我不确定如何在C ++中使用TensorFlow(我参加了在Python中而不是C ++中使用TensorFlow的Udemy.com课程(https://www.udemy.com/course/machinelearning/),因为这样做的唯一提法是说需要这样做在Windows中?是吗?

TensorFlow在以下64位系统上经过测试和支持:

  • Python 3.5–3.8
  • Ubuntu 16.04或更高版本
  • Windows 7或更高版本(可重新分发C ++)
  • macOS 10.12.6(Sierra)或更高版本(不支持GPU)
  • Raspbian 9.0或更高版本 https://www.tensorflow.org/install

两个问题似乎是:

第一

Udacity C ++课程使用以下链接推荐的#includes:https://www.tensorflow.org/guide/create_op

#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"

这两个文件在我的Ubuntu 18.04.4 LTS虚拟机中的实际位置

#include "./.local/lib/python2.7/site-packages/tensorflow_core/include/tensorflow/core/framework/op.h"
#include "./.local/lib/python2.7/site-packages/tensorflow_core/include/tensorflow/core/framework/shape_inference.h"

#include都不能在Visual Studio代码中说“无法打开源文件”

第二

在安装过程中出现以下错误:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: tensorboard 2.1.0 has requirement setuptools>=41.0.0, but you'll have setuptools 39.0.1 which is incompatible.
ERROR: google-auth 1.18.0 has requirement setuptools>=40.3.0, but you'll have setuptools 39.0.1 which is incompatible.
  WARNING: The scripts f2py, f2py2 and f2py2.7 are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script chardetect is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script google-oauthlib-tool is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown_py is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tensorboard is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts estimator_ckpt_converter, saved_model_cli, tensorboard, tf_upgrade_v2, tflite_convert, toco and toco_from_protos are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

完整的安装文本输出在GitHub项目README(https://github.com/ProfHariSeldon/CppND-Capstone-Hello-World/blob/master/README.md)中,因为论坛不允许我将其放在这篇文章中,因为它“看起来像垃圾邮件”

更新

编辑:我升级到Ubuntu 20.04(如下所示),并且摆脱了两个错误,但是警告仍然存在。我仍然无法使#include正常工作,#include是否缺少任何内容?

  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown_py is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script google-oauthlib-tool is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tensorboard is installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts estimator_ckpt_converter, saved_model_cli, tensorboard, tf_upgrade_v2, tflite_convert, toco and toco_from_protos are installed in '/home/tlroot/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

我注意到该指南:https://medium.com/createdd-notes/install-tensorflow-with-virtuelenv-and-visual-studio-code-on-mac-6b9f93f0fb08 关于如何在Visual Studio Code中安装TensorFlow,请说: “设置Visual Studio代码 安装Visual Studio Python扩展程序“ https://marketplace.visualstudio.com/items?itemName=ms-python.python

我明天会尝试,但是我不知道是否能解决这个问题,因为该项目的重点是执行TensorFlow C ++项目而不是Python项目。

0 个答案:

没有答案