I'm trying to submit the following toy snippet as a job in GCP ml-engine:
import tensorflow as tf
import numpy as np
import scipy.misc
x = np.zeros([10, 10, 1])
y = scipy.misc.imresize(x[:, :, 0], [50, 50, 1], interp='nearest')
print(y)
print(y.shape)
It is giving the following error after the job starts on server:
File "/root/.local/lib/python2.7/site-packages/teste/test.py", line 6, in <module>
y = scipy.misc.imresize(x[:, :, 0], [50, 50, 1], interp='nearest')
AttributeError: 'module' object has no attribute 'imresize'
It works perfectly on local, and according to Cloud-ML docs, the scipy package is supported. Apparently it is not an issue with the module itself, as the import statement is not giving any error.
scipy.misc.imresize
requires PIL to be installed, which you probably have installed locally (since it works).
To ensure your code runs correctly in the cloud, you need to ensure pillow
is installed. If you have created your own setup.py
include pillow
in the list of requirements. If you have to create your own, create a setup.py
like this:
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = ['pillow']
setup(
name='trainer',
version='0.1',
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True,
description='My trainer application package.'
)
(source, with one important modification, the packages
attribute)
See the official CloudML Engine documentation for more information about recommended directory layout and packaging instructions.