From 940395c54584980e51aaf492bb2cce73041d65d3 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Tue, 6 Aug 2024 10:18:27 -0700 Subject: [PATCH] Run the Tensorflow examples as part of Tensorflow image build process. This is a bit silly but it is quite light on CPU and runs pretty fast. This ensures that all the prerequisite models are predownloaded into the image. Without this, the image fails when running with networking disabled. PiperOrigin-RevId: 660004352 --- images/benchmarks/tensorflow/Dockerfile.x86_64 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/images/benchmarks/tensorflow/Dockerfile.x86_64 b/images/benchmarks/tensorflow/Dockerfile.x86_64 index 7564a4ee5..0886f4dc1 100644 --- a/images/benchmarks/tensorflow/Dockerfile.x86_64 +++ b/images/benchmarks/tensorflow/Dockerfile.x86_64 @@ -5,3 +5,18 @@ RUN apt-get update \ RUN git clone --depth 1 https://github.com/aymericdamien/TensorFlow-Examples.git RUN python -m pip install -U pip setuptools RUN python -m pip install matplotlib + +# Run the Tensorflow examples; they use the CPU only, but what we want here +# is the side-effect of pre-downloading the models they will use. +RUN export PYTHONPATH=$PYTHONPATH:/TensorFlow-Examples/examples; \ + cd /TensorFlow-Examples/examples; \ + examples=' \ + 2_BasicModels/kmeans.py \ + 2_BasicModels/logistic_regression.py \ + 2_BasicModels/nearest_neighbor.py \ + 2_BasicModels/random_forest.py \ + 3_NeuralNetworks/convolutional_network.py \ + 3_NeuralNetworks/multilayer_perceptron.py \ + 3_NeuralNetworks/neural_network.py \ + '; \ + for f in $examples; do python "$f"; done