Google ML引擎中的构建轮失败

时间:2017-12-12 05:21:26

标签: gcloud google-cloud-ml

我按照此tutorial向Google ML引擎提交机器学习作业。然后我遇到了错误ImportError: No module named matplotlib.pyplot但是通过在setup.py中将Matplotlib添加到RequiredPackages来解决它。然后我面临另一个错误ImportError: No module named _tkinter, please install the python-tk package。我发现了这个solutionsolution,但没有帮助,又给了我一个错误。

  

my-package的构建轮失败

     

命令“/ usr / bin / python -u -c”import setuptools,tokenize; file ='/ tmp / pip-T6kjZl-build / setup.py'; f = getattr(tokenize ,'打开',打开)(文件); code = f.read()。replace('\ r \ n','\ n'); f.close(); exec(编译(代码,文件,'exec'))“install --record /tmp/pip-4LpzWh-record/install-record.txt --single-version-external-managed --compile - 用户--prefix =“失败,错误代码为1 / tmp / pip-T6kjZl-build /

     

命令'['pip','install',' - user',' - upgrade',' - force-reinstall',' - no-deps',u'my-package-0.1。 1.tar.gz']'返回非零退出状态1

我的setup.py。

"""Setup script for object_detection."""
import logging
import subprocess
from setuptools import find_packages
from setuptools import setup
from setuptools.command.install import install

class CustomCommands(install):
    def RunCustomCommand(self, command_list):
        p = subprocess.Popen(
        command_list,
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)
        # Can use communicate(input='y\n'.encode()) if the command run requires
        # some confirmation.
        stdout_data, _ = p.communicate()
        logging.info('Log command output: %s', stdout_data)
        if p.returncode != 0:
            raise RuntimeError('Command %s failed: exit code: %s', (command_list, p.returncode))

    def run(self):
        self.RunCustomCommand(['apt-get', 'update'])
        self.RunCustomCommand(
        ['apt-get', 'install', '-y', 'python-tk'])
        install.run(self)

REQUIRED_PACKAGES = ['Pillow>=1.0', 'Matplotlib>=2.1']
setup(
name='object_detection',
version='0.1',
install_requires=REQUIRED_PACKAGES,
include_package_data=True,
packages=[p for p in find_packages() if
p.startswith('object_detection')],
description='Tensorflow Object Detection Library',
cmdclass={
    'install': CustomCommands,
})

1 个答案:

答案 0 :(得分:0)

我认为您关注的教程博客链接已过时。我在下面关注 https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pets.md

您需要在Cloud ml培训命令中将运行时更改为1.9,而不是1.8

From tensorflow/models/research/
gcloud ml-engine jobs submit training `whoami`_object_detection_pets_`date +%m_%d_%Y_%H_%M_%S` \
    --runtime-version 1.9 \
    --job-dir=gs://${YOUR_GCS_BUCKET}/model_dir \
    --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
    --module-name object_detection.model_main \
    --region us-central1 \
    --config object_detection/samples/cloud/cloud.yml \
    -- \
    --model_dir=gs://${YOUR_GCS_BUCKET}/model_dir \
    --pipeline_config_path=gs://${YOUR_GCS_BUCKET}/data/faster_rcnn_resnet101_pets.config

更改运行时后,一切运行正常。无需更改任何安装文件。没有库错误。