【问题标题】:Failed building wheel in Google ML engine在 Google ML 引擎中构建轮子失败
【发布时间】:2017-12-12 05:21:25
【问题描述】:

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

我的包的构建轮子失败

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-T6kjZl-build/setup.py';f=getattr(tokenize , 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile (code, file, 'exec'))" install --record /tmp/pip-4LpzWh-record/install-record.txt --single-version-externally-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,
})

【问题讨论】:

  • 您介意复制完整的 setup.py 并可能提供更多日志吗?
  • 我添加了setup.py。其实我已经把所有的日志都贴出来了。
  • 我复制了你的 setup.py 并做了一个小改动:我设置了 package=find_packages()。然后我创建了一个简单的 main.py: import matplotlib.pyplot import _tkinter print "Hello, world!"提交了作业,并且成功了。 gcloud ml-engine jobs submit training matplotlib --package-path=a --module-name="a.main" --staging-bucket=gs://my-bucket
  • 我尝试浏览博文。很多小错误,我会提交补丁。我尝试逐字使用您的 setup.py 文件,它似乎有效,也就是说,我没有收到与您看到的相同的错误。也就是说,我仍然收到有关缺少方法的错误。我也会尝试修复和修补它。
  • 它正在与 --runtime-version=1.2 一起使用!

标签: gcloud google-cloud-ml


【解决方案1】:

我认为您关注的教程博客链接已过时。我关注了this one 您需要在 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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-11
    • 2018-01-07
    • 2017-03-17
    • 2020-11-09
    • 2018-05-31
    • 2018-06-17
    • 2019-11-11
    • 2022-06-19
    相关资源
    最近更新 更多