【发布时间】:2018-12-13 07:35:29
【问题描述】:
我是 docker 的新手,但我已经搜索了很多关于我面临的问题。
我有一个代码,我在其中使用 tensorflow、PyQt 和其他包。现在,我拉出了tensorflow/tensorflow:1.4.0-gpu-py3 和nvidia/cuda:8.0-cudnn6-runtime。此外,我还构建了具有一些依赖项的应用程序映像。
我尝试使用 docker-compose 运行上述所有图像,如下所示:
version: '3'
services:
nvidia:
image: "nvidia/cuda:8.0-cudnn6-runtime"
tensorflow:
image: "tensorflow/tensorflow:1.4.0-gpu-py3"
app:
image: my_app
但我收到错误ImportError: No module named 'tensorflow'。
请通过建议我应该解决这个问题的方式来帮助我。
编辑:
以下代码示例只是我的几行代码。
import sys
from PyQt5 import QtCore, QtGui, QtQml, QtQuick
from OpenGL import GL
import cv2 # .cv2 as cv2
from multiprocessing import Process,Queue, Value, Manager
import os
import tensorflow as tf
编辑:
# Use an official Python runtime as a parent image
FROM ubuntu:16.04
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
RUN \
apt-get update && \
apt-get install -y python python-dev python-pip python-virtualenv && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install -y libgtk2.0-dev python python-dev python3 python3-dev python3-pip
RUN apt-get update && apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
RUN pip install setuptools pip --upgrade --force-reinstall
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
#RUN apt-get update -y
# Install packages
#RUN apt-get install -y curl
#RUN apt-get install -y postgresql
#RUN apt-get install -y postgresql-client
#RUN apt-get install -y python3-numpy python3-opengl python-qt4 python-qt4-gl
# Run app.py when the container launches
CMD ["python3", "Working.py"]
requirement.txt
PyOpenGL
PyQt5
opencv-python
【问题讨论】:
-
请分享my_app图片代码
-
@Edmhs:我已经添加了。 working.py 是由qt 代码组成的简单图像分类代码。
标签: docker tensorflow docker-compose dockerfile docker-swarm