From 563c7a872539c12b3a7ce67740302672df7745d6 Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Fri, 20 Dec 2024 16:48:08 +0100 Subject: [PATCH] chore(tensorflow-cpu): add test with tf lib and move to stable py package Signed-off-by: Massimiliano Giovagnoli --- tensorflow-cpu.yaml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tensorflow-cpu.yaml b/tensorflow-cpu.yaml index f2b58feb2ae..17d6f2ebfa8 100644 --- a/tensorflow-cpu.yaml +++ b/tensorflow-cpu.yaml @@ -48,7 +48,7 @@ pipeline: --no-cache-dir \ --root ${{targets.contextdir}} \ --prefix ${{vars.prefix}} \ - tf-nightly + ${{vars.pypi-package}} - name: Install jupyter requirements runs: | @@ -68,6 +68,11 @@ pipeline: runs: | mkdir -p ${{targets.contextdir}}/tf/tensorflow-tutorials cp jupyter.readme.md ${{targets.contextdir}}/tf/tensorflow-tutorials/README.md + + - name: Cleanup pycache + runs: | + find . -name '__pycache__' -exec rm -rf {} + + test: environment: contents: @@ -80,6 +85,27 @@ test: - name: Test import of Tensorflow - runs: | python -c 'import tensorflow as tf' + - name: Test Tensorflow library + runs: | + cat <<"EOF" >test.py + import tensorflow as tf + + # Check TensorFlow version + print("TensorFlow version:", tf.__version__) + + # Check if TensorFlow can access the CPU + print("Is built with CUDA:", tf.test.is_built_with_cuda()) + print("Available devices:") + for device in tf.config.list_physical_devices(): + print(device) + + # Perform a simple computation + a = tf.constant([1.0, 2.0, 3.0]) + b = tf.constant([4.0, 5.0, 6.0]) + c = tf.add(a, b) + print("Result of addition:", c.numpy()) + EOF + python test.py - name: Test Juputer notebook run runs: | jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root >/dev/null 2>&1 &