简体   繁体   English

自定义 Python Remove Interpreter with OpenVINO 初始化

[英]Custom Python Remove Interpreter with OpenVINO initialization

I use PyCharm to connect to a remote interpreter (but I guess the answer is somewhat unrelated): basically, PyCharm connects to a remote Python interpreter through SSH and execute the code on a remote machine.我使用 PyCharm 连接到远程解释器(但我想答案有些无关):基本上,PyCharm 通过 SSH 连接到远程 Python 解释器并在远程机器上执行代码。

The remote interpreter that I used is actually "tweaked".我使用的远程解释器实际上是“调整”的。 It is a file called mypython that contains the following code:它是一个名为mypython的文件,其中包含以下代码:

#!/bin/bash -l
export PATH="/home/ubuntu/.local/bin:/usr/local/cuda-11.1/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:${PATH}"
export LD_LIBRARY_PATH="/home/ubuntu/.local/lib:/usr/local/cuda-11.1/lib64:/home/ubuntu/.local/lib:/usr/local/cuda-11.1/lib64:${LD_LIBRARY_PATH}"
export PYTHONPATH="/home/ubuntu/VideoProcessingFramework/install/bin:${PYTHONPATH}"
export PATH="/home/ubuntu/FFmpeg/build_x64_release_shared/bin:${PATH}"
export LD_LIBRARY_PATH="/home/ubuntu/VideoProcessingFramework/install/bin:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH="/home/ubuntu/FFmpeg/build_x64_release_shared/lib:${LD_LIBRARY_PATH}"

export PATH="/home/ubuntu/pytorch/build/bin:${PATH}"
export LD_LIBRARY_PATH="/home/ubuntu/pytorch/build/lib:${LD_LIBRARY_PATH}"

# My attempt at having OpenVINO working on PyCharm remote interpreter
export PYTHONPATH="${PYTHONPATH}:/opt/intel/openvino_2021.1.110/python/python3.6:/opt/intel/openvino_2021.1.110/python/python3:/opt/intel/openvino_2021.1.110/deployment_tools/tools/post_training_optimization_toolkit:/opt/intel/openvino_2021.1.110/deployment_tools/open_model_zoo/tools/accuracy_checker:/opt/intel/openvino_2021.1.110/deployment_tools/model_optimizer:/opt/intel/openvino_2021.1.110/data_processing/dl_streamer/python:/opt/intel/openvino_2021.1.110/data_processing/gstreamer/lib/python3.6/site-packages:/usr/lib/python3/dist-packages"
export OpenCV_DIR="/opt/intel/openvino_2021.1.110/opencv/cmake"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/intel/openvino_2021.1.110/data_processing/dl_streamer/lib:/opt/intel/openvino_2021.1.110/data_processing/gstreamer/lib:/opt/intel/openvino_2021.1.110/opencv/lib:/opt/intel/openvino_2021.1.110/deployment_tools/ngraph/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/external/hddl_unite/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/external/hddl/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/external/gna/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/external/mkltiny_lnx/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/external/tbb/lib:/opt/intel/openvino_2021.1.110/deployment_tools/inference_engine/lib/intel64"
export GST_SAMPLES_DIR="/opt/intel/openvino_2021.1.110/data_processing/dl_streamer/samples"
export MODELS_PATH="/root/intel/dl_streamer/models"
export PKG_CONFIG_PATH="/opt/intel/openvino_2021.1.110/data_processing/dl_streamer/lib/pkgconfig:/opt/intel/openvino_2021.1.110/data_processing/gstreamer/lib/pkgconfig:"
export GSTREAMER_EXECUTABLES_DIR="/opt/intel/openvino_2021.1.110/data_processing/gstreamer/bin:/opt/intel/openvino_2021.1.110/data_processing/gstreamer/bin/gstreamer-1.0"
export GST_PLUGIN_PATH="$GST_PLUGIN_PATH:/opt/intel/openvino_2021.1.110/data_processing/gstreamer/lib/gstreamer-1.0"
export GST_PLUGIN_SCANNER="/opt/intel/openvino_2021.1.110/data_processing/gstreamer/bin/gstreamer-1.0/gst-plugin-scanner"
export GST_VAAPI_ALL_DRIVERS=1


/usr/bin/python3 "$@"

This allows me to specify some environment variables required by Python.这允许我指定 Python 所需的一些环境变量。 Since I install OpenVINO on the remote machine, I would need to add to mypython code the command: source /opt/intel/openvino_2021.1.110/bin/setupvars.sh .由于我在远程机器上安装了 OpenVINO,我需要将命令添加到mypython代码中: source /opt/intel/openvino_2021.1.110/bin/setupvars.sh However, once I do this, it seems that PyCharm refuses to use my mypython interpreter (it just gets stuck).但是,一旦我这样做,PyCharm 似乎拒绝使用我的mypython解释器(它只是卡住了)。

Motivation:动机:

  • If I ssh into my remote machine and run source /opt/intel/openvino_2021.1.110/bin/setupvars.sh I can then import cv2 correctly from python3如果我通过 ssh 进入我的远程机器并运行source /opt/intel/openvino_2021.1.110/bin/setupvars.sh我可以从 python3 正确导入 cv2
  • From the PyCharm remote interpreter instead I get the error:从 PyCharm 远程解释器中,我得到了错误:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-c8ec22b3e787>", line 1, in <module>
    import cv2
ImportError: /opt/intel/openvino_2021.1.110/opencv/lib/libopencv_dnn.so.4.5: undefined symbol: _ZN15InferenceEngine10CNNNetworkC1ERKSt10shared_ptrIN6ngraph8FunctionEE

Possible solution:可能的解决方案:

  • log into the server using ssh使用 ssh 登录服务器
  • run source /opt/intel/openvino_2021.1.110/bin/setupvars.sh运行source /opt/intel/openvino_2021.1.110/bin/setupvars.sh
  • run printenv Include all the variables into the mypython source code.运行printenv所有变量包含到mypython源代码中。 I would still like to know if there is a way to run source /opt/intel/openvino_2021.1.110/bin/setupvars.sh within mypython source code.我仍然想知道是否有办法在mypython源代码中运行source /opt/intel/openvino_2021.1.110/bin/setupvars.sh

EDIT: in my case removing this from my environment variables fixed the issue:编辑:在我的情况下,从我的环境变量中删除它解决了这个问题:

export LD_LIBRARY_PATH="/home/ubuntu/.local/lib:/usr/local/cuda-11.1/lib64:/home/ubuntu/.local/lib:/usr/local/cuda-11.1/lib64:${LD_LIBRARY_PATH}"

Not sure if I had an old OpenCV version compiled with cuda.不确定我是否有使用 cuda 编译的旧 OpenCV 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过外壳初始化脚本拥有复杂的python应用程序(包括自定义解释器)的自然MacOSX .app? - How to have a natural MacOSX .app of a complex python application (including custom interpreter) via a shell initialization script? 如何使用包含初始化代码的zc.buildout生成自定义python解释器? - How can I generate a custom python interpreter using zc.buildout that includes my initialization code? importlib._bootstrap和python解释器初始化 - importlib._bootstrap and python interpreter initialization 带有 python 的 Openvino 返回一些错误 - Openvino with python is returning some error python ImportError Openvino by script 和 shell - python ImportError Openvino by script and by shell 使用自定义模块构建python解释器时出现问题 - Problems building python interpreter with custom module 将python解释器移植到自定义操作系统 - Porting the python interpreter to a custom operating system VSCode“Python:Select解释器”添加自定义路径 - VSCode “Python: Select interpreter” add a custom path 是否可以总结解释器初始化步骤? - Is it possible to summarize the Interpreter initialization steps? 如何从Eclipse中删除/添加python解释器? - How do I remove/add the python interpreter from eclipse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM