Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow-cpu: add new package #37597

Merged
merged 16 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions tensorflow-cpu.yaml
maxgio92 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#nolint:valid-pipeline-git-checkout-tag
package:
name: tensorflow-cpu
version: 0_git20250108
epoch: 0
description: tensorflow-cpu
copyright:
- license: Apache-2.0
target-architecture:
- x86_64
options:
# We're creating a virtual environment.
# Don't pull in other packages if dependencies are already vendored.
no-depends: true
# Don't install if something is vendored that another package depends on.
no-provides: true
dependencies:
runtime:
- bash
- build-base
- curl
- pkgconf
- py${{vars.py-version}}-pip
- python-${{vars.py-version}}
- unzip

vars:
py-version: 3.11
EyeCantCU marked this conversation as resolved.
Show resolved Hide resolved
pypi-package: tensorflow-cpu
shared: /usr/share/tensorflow

environment:
contents:
packages:
- build-base
- busybox
- py${{vars.py-version}}-pip
- python-${{vars.py-version}}
environment:
# This is needed to work around the error "ValueError: ZIP does not support timestamps before 1980"
SOURCE_DATE_EPOCH: 315532800

pipeline:
- uses: git-checkout
with:
expected-commit: e23ae5591020ef3cb2917293ed92af7ea70bcdb1
repository: https://github.com/tensorflow/build
branch: master

- working-directory: tensorflow_runtime_dockerfiles
pipeline:
- name: Check latest supported Python version
- runs: |
PYTHON_VERSION=$(grep -E "^ARG PYTHON_VERSION" cpu.Dockerfile | cut -d '=' -f2 | sed 's|python||g')
test "${{vars.py-version}}" == "${PYTHON_VERSION}" || \
{ echo "error: Python version does not match the latest supported version: want: ${{vars.py-version}} got: ${PYTHON_VERSION} from $(grep -H -n -E '^ARG PYTHON_VERSION' cpu.Dockerfile)" && exit 1; }
- name: Create virtual environment
runs: |
python -m venv .venv
- name: Install cpu requirements
runs: |
source .venv/bin/activate
pip install \
--no-cache-dir \
-r cpu.requirements.txt
- name: Install Tensorflow
runs: |
source .venv/bin/activate
pip install \
--no-cache-dir \
${{vars.pypi-package}}
- name: Install jupyter requirements
runs: |
source .venv/bin/activate
pip install \
--no-cache-dir \
-r jupyter.requirements.txt \
-U
- name: Cleanup the virtual environment
runs: |
find .venv -name "*.pyc" -delete
find .venv -name "__pycache__" -exec rm -rf {} +
- name: Install the virtual environment
runs: |
mkdir -p ${{targets.contextdir}}/${{vars.shared}}
mv .venv/* ${{targets.contextdir}}/${{vars.shared}}
sed -i "s|/home/build/tensorflow_runtime_dockerfiles/.venv|${{vars.shared}}|g" ${{targets.contextdir}}/${{vars.shared}}/bin/*
- name: Install bashrc
runs: |
mkdir -p ${{targets.contextdir}}/etc
cp bashrc ${{targets.contextdir}}/etc/bash.bashrc
- name: Install tensorflow tutorials
runs: |
mkdir -p ${{targets.contextdir}}/tf/tensorflow-tutorials
cp jupyter.readme.md ${{targets.contextdir}}/tf/tensorflow-tutorials/README.md

test:
environment:
contents:
packages:
- curl
maxgio92 marked this conversation as resolved.
Show resolved Hide resolved
maxgio92 marked this conversation as resolved.
Show resolved Hide resolved
environment:
PYTHONPATH: ${{vars.shared}}/lib/python${{vars.py-version}}/site-packages
pipeline:
- name: Test import of IPython kernel for Jupyter
uses: python/import
with:
imports: |
import ipykernel.kernelspec
- name: Test Tensorflow library
maxgio92 marked this conversation as resolved.
Show resolved Hide resolved
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 Jupyter notebook run
uses: test/daemon-check-output
with:
start: |
${{vars.shared}}/bin/jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root
post: |
curl --fail --location --request GET --head --silent localhost:8888
expected_output: "is running at:"
timeout: 10

update:
enabled: true
git: {}
schedule:
period: daily
reason: Upstream does not maintain tags or releases
Loading