models icon indicating copy to clipboard operation
models copied to clipboard

Evaluation step for pets demo does not work in Google Cloud ML engine

Open jhovell opened this issue 8 years ago • 53 comments

When following the step described here in the documentation an error is thrown about pycocotools being missing.

This issue is described here as well as on a Stack Overflow thread, but the workaround/fix described in either place is to install a plaform-specific version of Pycocotools locally. I'm skeptical that installing pycocotools on my Mac is going to fix this running in Google Cloud ML Engine. At the very least I'd expect to somehow have to bundle some Linux variant as a package along with my job. Is there any documentation how to achieve this or is this step currently broken with Google Cloud ML engine?

jhovell avatar Feb 26 '18 19:02 jhovell

Can you include the exact commands you are using?

angerson avatar Feb 26 '18 19:02 angerson

Please follow the COCO API installation section described here.

pkulzc avatar Feb 26 '18 20:02 pkulzc

I have the same issue as @jhovell . The pycocotools are installed on my machine, and so local train and eval works. But GoogleCloud eval does not work, due to the pycococo error. I had uploaded the pycococotools to GoogleCloud via object_detection and slim package, but that too did not resolve the issue.

josh-a-dcosta avatar Feb 27 '18 19:02 josh-a-dcosta

thanks @angersson . I basically just used the steps in this demo which links to the "Running on Google Cloud Platform" docs in this repo.

Here is a bash script with the exact command I am running. The constants refer to private Google Cloud buckets used to store my config, eval and training data.

#!/bin/bash

TRAIN_DIR=raccoon-training-d475e1a4
PIPELINE_CONFIG_PATH=raccoon-config-d475e1a4/ssd_mobilenet_v1_pets.config
EVAL_DIR=raccoon-eval-d475e1a4

set -e

gcloud ml-engine jobs submit training object_detection_eval_`date +%s` \
    --runtime-version 1.4 \
    --job-dir=gs://${TRAIN_DIR} \
    --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz \
    --module-name object_detection.eval \
    --region us-central1 \
    --scale-tier BASIC_GPU \
    -- \
    --checkpoint_dir=gs://${TRAIN_DIR} \
    --eval_dir=gs://${EVAL_DIR} \
    --pipeline_config_path=gs://${PIPELINE_CONFIG_PATH}

Same experience as @agnellodcosta ... So you're saying there is no need to perform extra steps to somehow package pycocotools and submit with my job in google cloud, it's just supposed to work on google cloud ml engine after compiling and installing locally on my mac?

jhovell avatar Feb 27 '18 22:02 jhovell

I have tried placing pycocotools in models/research, models/research/object_detection, and models/research/object_detection/metrics, re-run the python setup.py sdist && cd slim && python setup.py sdist commands, and seen the same error each time. I am also receiving a Runtime error saying that I'm using numpy version 0xa when I should be using 0xb, even though I have added numpy==1.11 as a required dependency to models/research/setup.py.

maxwang7 avatar Feb 28 '18 08:02 maxwang7

I tried to install pycocotools with editing setup.py

REQUIRED_PACKAGES = ['Pillow>=1.0', 'Matplotlib>=2.1', 'Cython>=0.28', 'pycocotools>=2.0.0']

but failed.

Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-0CFyea/pycocotools/setup.py", line 2, in <module> from Cython.Build import cythonize ImportError: No module named Cython.Build

I think Cython does not install correctly. Someone any idea?

bduman avatar Mar 15 '18 17:03 bduman

Run into the same issue on Google Cloud, any update on this?

wenhuiyao avatar Mar 20 '18 17:03 wenhuiyao

Check this issue, #3431

josh-a-dcosta avatar Mar 23 '18 13:03 josh-a-dcosta

@agnellodcosta your solution almost same mine. Could you eval on cloud successfully ?

bduman avatar Mar 23 '18 14:03 bduman

@bduman train works with the solution @agnellodcosta posted, but I cannot run eval. Still have issues with the pycocotools import. Error is as follows:

import pycocotools._mask as _mask ImportError: No module named _mask

any ideas?

joshbarrington avatar Mar 23 '18 18:03 joshbarrington

I am getting similar errors. The documentation is definitely missing a step of how to install pycocotools correctly on gcloud. In my opinion it should be a separate package - just as object_detection and slim are. But building it as a package gives me this error Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-SqFrWm-build/setup.py", line 23, in <module> cythonize(ext_modules) File "/root/.local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 897, in cythonize aliases=aliases) File "/root/.local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 777, in create_extension_list for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern): File "/root/.local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 102, in nonempty raise ValueError(error_msg) ValueError: 'pycocotools/_mask.pyx' doesn't match any files

This is because there seems to be a bug in pycocotools setup script

choudharydhruv avatar Mar 25 '18 00:03 choudharydhruv

I managed to get eval to run by including pycocotools as a package. Copy the common folder from cocoapi into the cocoapi/PythonAPI directory.

Edit the setup.py file in PythonAPI so any reference to the common folder does not include changing back a directory e.g. change ../common to just common.

In PythonAPI/pycocotools, modify line 2 in the _mask.pyx file also.

Tar the entire PythonAPI file, rename as "pycocotools-2.0" and include this compressed file as a package in the --packages flag when you submit the job to the gcloud ml-engine

joshbarrington avatar Mar 25 '18 16:03 joshbarrington

Eval is running, but seems to be stuck on the first checkpoint it evaluates from the train directory. New checkpoints are saved but the log Found already evaluated checkpoint. Will try again in 300 seconds is repeated every attempt of evaluation even if new checkpoints are there.

Anyone had or dealt with this issue?

joshbarrington avatar Mar 25 '18 21:03 joshbarrington

I had the same issue. As suggested here, setting environment variable GCS_READ_CACHE_MAX_SIZE_MB to 0 helped me.

I simply added these two lines to object_detection/__init__ file:

import os
os.environ['GCS_READ_CACHE_MAX_SIZE_MB'] = '0'

However, I would appreciate any suggestion for a cleaner solution.

dvoram avatar Mar 26 '18 15:03 dvoram

Hi @Joshbarrington, thanks for your solution. I have tried your method, however it returned another error.

Command '['pip', 'install', '--user', '--upgrade', '--force-reinstall', '--no-deps', u'pycocotools-2.0']' returned non-zero exit status 1

I have used command tar -czvf pycocotools-2.0 PythonAPI/ to compress it, and use --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,pycocotools-2.0 \ to attach the package.

Im a noob in GCP ML, is there anything wrong with my way of doing it? thanks

nehcgnem avatar Mar 27 '18 20:03 nehcgnem

Hi @Joshbarrington this is the error message with--packages pycocotools-2.0 Could not find a version that satisfies the requirement pycocotools-2.0 (from versions: )

Thanks

nehcgnem avatar Mar 28 '18 03:03 nehcgnem

@bduman I got the same issue as yours, google cloud couldn't install Cython.build

nehcgnem avatar Mar 28 '18 05:03 nehcgnem

@nehcgnem make sure your reference in the flag contains the .tar.gz and the path to the compressed file: such as: --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz, path/to/pycocotools-2.0.tar.gz \

Try adding 'Cython>=0.28.1 ' to your REQUIRED_PACKAGES in setup.py

joshbarrington avatar Mar 28 '18 12:03 joshbarrington

@dvoram When adding those two lines to file, I get the following corruption error:

W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at iterator_ops.cc:870 : Data loss: corrupted record at 147651135

Is this something you dealt with?

joshbarrington avatar Mar 28 '18 14:03 joshbarrington

No, I actually encountered a different error:

I tensorflow/core/platform/cloud/retrying_utils.cc:77] The operation failed and will be automatically retried in 1.08566 seconds (attempt 1 out of 10), caused by: Unavailable: Error executing an HTTP request (HTTP response code 502, error code 0, error message '')

And I "resolved" it by updating to runtime version 1.5.

Nevertheless, your problem seems to really be a file corruption. Is the file readable locally? Perhaps, recreating and reuploading may help...

dvoram avatar Mar 28 '18 14:03 dvoram