2024-11-07 13:17:29 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-09-07 23:48:40 +05:30
|
|
|
# This script build the CPU docker image and run the offline inference inside the container.
|
|
|
|
|
# It serves a sanity check for compilation and basic model usage.
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
|
|
# Setup cleanup
|
2025-04-24 22:36:17 +05:30
|
|
|
remove_docker_container() {
|
|
|
|
|
if [[ -n "$container_id" ]]; then
|
2025-06-07 00:24:26 +05:30
|
|
|
podman stop --all -t0
|
2025-04-24 22:36:17 +05:30
|
|
|
podman rm -f "$container_id" || true
|
|
|
|
|
fi
|
|
|
|
|
podman system prune -f
|
|
|
|
|
}
|
2024-09-07 23:48:40 +05:30
|
|
|
trap remove_docker_container EXIT
|
|
|
|
|
remove_docker_container
|
|
|
|
|
|
2024-11-23 15:03:53 +05:30
|
|
|
# Try building the docker image
|
2025-04-17 08:17:47 +05:30
|
|
|
podman build -t cpu-test-ubi9-ppc -f docker/Dockerfile.ppc64le .
|
|
|
|
|
|
|
|
|
|
# Run the image
|
2025-04-24 22:36:17 +05:30
|
|
|
container_id=$(podman run -itd --entrypoint /bin/bash -v /tmp/:/root/.cache/huggingface --privileged=true --network host -e HF_TOKEN cpu-test-ubi9-ppc)
|
2025-04-17 08:17:47 +05:30
|
|
|
|
|
|
|
|
function cpu_tests() {
|
|
|
|
|
|
|
|
|
|
# offline inference
|
2025-04-24 22:36:17 +05:30
|
|
|
podman exec -it "$container_id" bash -c "
|
2025-04-17 08:17:47 +05:30
|
|
|
set -e
|
|
|
|
|
python3 examples/offline_inference/basic/generate.py --model facebook/opt-125m"
|
|
|
|
|
|
|
|
|
|
# Run basic model test
|
2025-04-24 22:36:17 +05:30
|
|
|
podman exec -it "$container_id" bash -c "
|
2025-04-17 08:17:47 +05:30
|
|
|
set -e
|
|
|
|
|
pip install pytest pytest-asyncio einops peft Pillow soundfile transformers_stream_generator matplotlib
|
|
|
|
|
pip install sentence-transformers datamodel_code_generator
|
2025-05-12 13:41:55 +05:30
|
|
|
pytest -v -s tests/models/language/generation/test_bart.py -m cpu_model
|
|
|
|
|
pytest -v -s tests/models/language/generation/test_common.py::test_models[False-5-32-openai-community/gpt2]
|
|
|
|
|
pytest -v -s tests/models/language/generation/test_common.py::test_models[False-5-32-facebook/opt-125m]
|
|
|
|
|
pytest -v -s tests/models/language/generation/test_common.py::test_models[False-5-32-google/gemma-1.1-2b-it]
|
|
|
|
|
pytest -v -s tests/models/language/pooling/test_classification.py::test_models[float-jason9693/Qwen2.5-1.5B-apeach]
|
2025-06-07 09:22:52 +05:30
|
|
|
pytest -v -s tests/models/language/pooling/test_embedding.py -m cpu_model"
|
2025-04-17 08:17:47 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# All of CPU tests are expected to be finished less than 40 mins.
|
2025-04-24 22:36:17 +05:30
|
|
|
|
|
|
|
|
export container_id
|
2025-04-17 08:17:47 +05:30
|
|
|
export -f cpu_tests
|
|
|
|
|
timeout 40m bash -c cpu_tests
|
2024-11-09 11:27:11 +08:00
|
|
|
|