Python 3.x 如何从Dockerfile运行环境初始化shell脚本
我正在尝试构建一个封装在docker映像中的API,该映像为Openvino模型服务。如何从Dockerfile本身运行“setupvars.sh”,以便我的应用程序可以访问它 我已尝试使用RUN运行脚本。例如:RUN/bin/bash setupvars.sh 或运行./setupvars.sh。但是,它们都不工作,我得到ModelNotFoundError:没有名为openvino的模块Python 3.x 如何从Dockerfile运行环境初始化shell脚本,python-3.x,docker,openvino,Python 3.x,Docker,Openvino,我正在尝试构建一个封装在docker映像中的API,该映像为Openvino模型服务。如何从Dockerfile本身运行“setupvars.sh”,以便我的应用程序可以访问它 我已尝试使用RUN运行脚本。例如:RUN/bin/bash setupvars.sh 或运行./setupvars.sh。但是,它们都不工作,我得到ModelNotFoundError:没有名为openvino的模块 RUN $INSTALL_DIR/install_dependencies/install_openvi
RUN $INSTALL_DIR/install_dependencies/install_openvino_dependencies.sh
RUN cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites && sudo ./install_prerequisites_tf.sh
COPY . /app
WORKDIR /app
RUN apt autoremove -y && \
rm -rf /openvino /var/lib/apt/lists/*
RUN /bin/bash -c "source $INSTALL_DIR/bin/setupvars.sh"
RUN echo "source $INSTALL_DIR/bin/setupvars.sh" >> /root/.bashrc
CMD ["/bin/bash"]
RUN python3 -m pip install opencv-python
RUN python3 test.py
我希望我的gunicorn应用程序可以访问OpenVino,该应用程序将在docker映像中为模型提供服务
ARG OPENVINO_DIR=/opt/intel/computer_vision_sdk
# Unzip the OpenVINO installer
RUN cd ${APP_DIR} && tar -xvzf l_openvino_toolkit*
# installing OpenVINO dependencies
RUN cd ${APP_DIR}/l_openvino_toolkit* && \
./install_cv_sdk_dependencies.sh
# installing OpenVINO itself
RUN cd ${APP_DIR}/l_openvino_toolkit* && \
sed -i 's/decline/accept/g' silent.cfg && \
./install.sh --silent silent.cfg
# Setup the OpenVINO environment
RUN /bin/bash -c "source ${OPENVINO_DIR}/bin/setupvars.sh"
下一个命令对我有用
ARG OPENVINO_DIR=/opt/intel/computer_vision_sdk
# Unzip the OpenVINO installer
RUN cd ${APP_DIR} && tar -xvzf l_openvino_toolkit*
# installing OpenVINO dependencies
RUN cd ${APP_DIR}/l_openvino_toolkit* && \
./install_cv_sdk_dependencies.sh
# installing OpenVINO itself
RUN cd ${APP_DIR}/l_openvino_toolkit* && \
sed -i 's/decline/accept/g' silent.cfg && \
./install.sh --silent silent.cfg
# Setup the OpenVINO environment
RUN /bin/bash -c "source ${OPENVINO_DIR}/bin/setupvars.sh"
每次启动容器时都需要重新运行它,因为这些变量仅用于会话 备选案文1: 按如下方式运行应用程序:
CMD /bin/bash -c "source /opt/intel/openvino/bin/setupvars.sh && python test.py"
选项2(未测试):
将源命令添加到.bashrc中,以便每次启动时都运行该命令
# Assuming running as root
RUN echo "/bin/bash -c 'source /opt/intel/openvino/bin/setupvars.sh'" >> ~root/.bashrc
CMD python test.py
对于Dockerfile的其余部分,这里有一个指南(也未测试,并且没有涵盖上述内容):
每次启动容器时都需要重新运行它,因为这些变量仅用于会话 备选案文1: 按如下方式运行应用程序:
CMD /bin/bash -c "source /opt/intel/openvino/bin/setupvars.sh && python test.py"
选项2(未测试):
将源命令添加到.bashrc中,以便每次启动时都运行该命令
# Assuming running as root
RUN echo "/bin/bash -c 'source /opt/intel/openvino/bin/setupvars.sh'" >> ~root/.bashrc
CMD python test.py
对于Dockerfile的其余部分,这里有一个指南(也未测试,并且没有涵盖上述内容):
对我来说仍然不起作用。获取相同的模块not found Error对我来说仍然不起作用。获取相同的模块未找到错误