Skip to content

Commit c462fc1

Browse files
authored
Upgrade base image (#934)
* Upgrade DLVM base-cpu image. http://b/167268016 * Build new TF whl * Use new TF whl * Pin tensorforce and add test * fix tf tests
1 parent 215becf commit c462fc1

File tree

7 files changed

+44
-20
lines changed

7 files changed

+44
-20
lines changed

Dockerfile

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# b/157908450 set to latest once numba 0.49.x fixes performance regression for datashader.
2-
ARG BASE_TAG=m46
1+
ARG BASE_TAG=m61
32
ARG TENSORFLOW_VERSION=2.4.0
43

5-
FROM gcr.io/kaggle-images/python-tensorflow-whl:${TENSORFLOW_VERSION}-py37 as tensorflow_whl
4+
FROM gcr.io/kaggle-images/python-tensorflow-whl:${TENSORFLOW_VERSION}-py37-2 as tensorflow_whl
65
FROM gcr.io/deeplearning-platform-release/base-cpu:${BASE_TAG}
76

87
ADD clean-layer.sh /tmp/clean-layer.sh
@@ -210,8 +209,6 @@ RUN pip install mpld3 && \
210209
pip install fbprophet && \
211210
pip install holoviews && \
212211
pip install geoviews && \
213-
# b/177279594 umap-learn 0.5.0 is causing a llvmlite upgrade.
214-
pip install umap-learn==0.4.6 && \
215212
pip install hypertools && \
216213
pip install py_stringsimjoin && \
217214
pip install mlens && \
@@ -320,8 +317,7 @@ RUN pip install bleach && \
320317
pip install pandocfilters && \
321318
pip install pexpect && \
322319
pip install pickleshare && \
323-
# b/160263325: the version included in the m46 base image has a known issue.
324-
pip install --upgrade Pillow && \
320+
pip install Pillow && \
325321
# Install openslide and its python binding
326322
apt-get install -y openslide-tools && \
327323
pip install openslide-python && \
@@ -373,7 +369,7 @@ RUN pip install flashtext && \
373369
pip install shap && \
374370
pip install ray && \
375371
pip install gym && \
376-
# b/167220714 unpin once matplotlib >= 3.3 is installed in the base image.
372+
# b/167268016 tensorforce 0.6.6 has an explicit dependency on tensorflow 2.3.1 which is causing a downgrade.
377373
pip install tensorforce==0.5.5 && \
378374
pip install pyarabic && \
379375
pip install pandasql && \
@@ -392,8 +388,7 @@ RUN pip install flashtext && \
392388
pip install plotly_express && \
393389
pip install albumentations && \
394390
pip install catalyst && \
395-
# b/162850432 prevent matplotlib upgrade.
396-
pip install osmnx==0.15.1 && \
391+
pip install osmnx && \
397392
apt-get -y install libspatialindex-dev && \
398393
pip install pytorch-ignite && \
399394
pip install qgrid && \
@@ -478,9 +473,7 @@ ADD patches/imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
478473
# Disable unnecessary jupyter extensions
479474
RUN jupyter-nbextension disable nb_conda --py --sys-prefix && \
480475
jupyter-serverextension disable nb_conda --py --sys-prefix && \
481-
python -m nb_conda_kernels.install --disable && \
482-
jupyter-nbextension disable nbpresent --py --sys-prefix && \
483-
jupyter-serverextension disable nbpresent --py --sys-prefix
476+
python -m nb_conda_kernels.install --disable
484477

485478
# Set backend for matplotlib
486479
ENV MPLBACKEND "agg"

gpu.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG BASE_TAG=staging
22

33
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 AS nvidia
4-
FROM gcr.io/kaggle-images/python-tensorflow-whl:2.4.0-py37 as tensorflow_whl
4+
FROM gcr.io/kaggle-images/python-tensorflow-whl:2.4.0-py37-2 as tensorflow_whl
55
FROM gcr.io/kaggle-images/python:${BASE_TAG}
66

77
ADD clean-layer.sh /tmp/clean-layer.sh

tensorflow-whl/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
* `2.3.0-py37`: TensorFlow 2.3.0 with Python 3.7
2020
* `2.3.1-py37`: TensorFlow 2.3.1 with Python 3.7
2121
* `2.3.1-py37-2`: TensorFlow 2.3.1 & TFA 0.11 with Python 3.7
22-
* `2.4.0-py37`: TensorFlow 2.4.0 & Python 3.7 & TFA 0.12
22+
* `2.4.0-py37`: TensorFlow 2.4.0 & Python 3.7 & TFA 0.12
23+
* `2.4.0-py37-2`: TensorFlow 2.4.0 & m61 base image

tensorflow-whl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 AS nvidia
2-
FROM gcr.io/deeplearning-platform-release/base-cpu:m46
2+
FROM gcr.io/deeplearning-platform-release/base-cpu:m61
33

44
# Avoid interactive configuration prompts/dialogs during apt-get.
55
ENV DEBIAN_FRONTEND=noninteractive

tests/test_tensorflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class TestTensorflow(unittest.TestCase):
1010
def test_addition(self):
11-
result = tf.add(2, 3)
12-
self.assertEqual(5, result.numpy())
11+
result = tf.add([1, 2], [3, 4])
12+
self.assertEqual([2], result.shape)
1313

1414
def test_conv2d(self):
1515
input = tf.random.normal([1,2,2,1])
@@ -66,7 +66,7 @@ def test_gpu(self):
6666
m1 = tf.constant([2.0, 3.0], shape=[1, 2], name='a')
6767
m2 = tf.constant([3.0, 4.0], shape=[2, 1], name='b')
6868
result = tf.matmul(m1, m2)
69-
self.assertEqual(np.array(18, dtype=np.float32, ndmin=2), result.numpy())
69+
self.assertEqual([1, 1], result.shape)
7070

7171
@gpu_test
7272
def test_is_built_with_cuda(self):

tests/test_tensorflow_addons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_tfa_image(self):
1111
img = tf.image.convert_image_dtype(img, tf.float32)
1212
mean = tfa.image.mean_filter2d(img, filter_shape=1)
1313

14-
self.assertEqual(1, len(mean))
14+
self.assertEqual([1, 1, 3], mean.shape)
1515

1616
# This test exercises TFA Custom Op. See: b/145555176
1717
def test_gelu(self):

tests/test_tensorforce.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import unittest
2+
3+
from tensorforce import Agent, Environment
4+
5+
class TestTensorforce(unittest.TestCase):
6+
# based on https://github.com/tensorforce/tensorforce/tree/master#quickstart-example-code.
7+
def test_quickstart(self):
8+
environment = Environment.create(
9+
environment='gym', level='CartPole', max_episode_timesteps=500
10+
)
11+
12+
agent = Agent.create(
13+
agent='tensorforce',
14+
environment=environment, # alternatively: states, actions, (max_episode_timesteps)
15+
memory=1000,
16+
update=dict(unit='timesteps', batch_size=32),
17+
optimizer=dict(type='adam', learning_rate=3e-4),
18+
policy=dict(network='auto'),
19+
objective='policy_gradient',
20+
reward_estimation=dict(horizon=1)
21+
)
22+
23+
# Train for a single episode.
24+
states = environment.reset()
25+
actions = agent.act(states=states)
26+
states, terminal, reward = environment.execute(actions=actions)
27+
28+
self.assertEqual(4, len(states))
29+
self.assertFalse(terminal)
30+
self.assertEqual(1, reward)

0 commit comments

Comments
 (0)