Sajid Ullah
Sajid Ullah

Reputation: 1

"ModuleNotFoundError: No module named 'pycocotools'" on google cloud compute

When I run the object detection API for custom dataset and initialize on google cloud compute. I got "no module error". I have all the module installed in conda env, then why the AI training didnt access the env python3.6 and its moduleenter image description here I have been through google cloud platform' initial documentation, but no material on this.

gcloud ai-platform jobs submit training object_detection_`date +%m_%d_%Y_%H_%M_%S` \
    --job-dir=gs://spike_detector/train \
    --packages /home/sajid/phd/spike_detector/models/research/dist/object_detection-0.1.tar.gz,/home/sajid/phd/spike_detector/models/research/slim/dist/slim-0.1.tar.gz \
    --module-name  object_detection.model_main \
    --region us-central1 \
    --python-version 3.7 \
    --runtime-version 1.15
    --config /home/sajid/phd/spike_detector/spike_detector_gscloud/training.yaml \
    -- \
    --train_dir=gs://spike_detector/train \
    --pipeline_config_path=gs://spike_detector/data/faster_rcnn_resnet101_pets.config

I got error ModuleNotFoundError: No module named 'pycocotools'

ERROR   2020-02-16 17:43:06 +0500   master-replica-0            from pycocotools import coco[enter image description here][2]
ERROR   2020-02-16 17:43:06 +0500   master-replica-0        ModuleNotFoundError: No module named 

Upvotes: 0

Views: 1360

Answers (1)

Daniel Duato
Daniel Duato

Reputation: 378

AI Platform runs its jobs in virtual machines specially configured for training jobs, so each dependency your job uses should be installed in those machines (having them on your local machine is not enough). Those virtual machines come with many packages already installed which can be checked here.

However pycocotools is not installed by default and you should explicitly instruct AI Platform to install it by specifying it in the job's setup.py file as explained here. This will download and install the dependency on the virtual machines using pip install.

Another way to install dependencies is to reference packages located in your local machine that will be staged in the cloud and then installed into the training machines, using the --packages flag as explained here. I see that you are already utilizing this feature to import other packages; you could try adding to it the location of the package pycocotools.

I hope that this can help you solve the error!

Upvotes: 1

Related Questions