diff --git a/dockerfiles/Dockerfile.source b/dockerfiles/Dockerfile.source index ea28e144ee95a..51291e59aa0d5 100644 --- a/dockerfiles/Dockerfile.source +++ b/dockerfiles/Dockerfile.source @@ -16,4 +16,4 @@ RUN cd /code && /bin/bash ./build.sh --allow_running_as_root --skip_submodule_sy FROM mcr.microsoft.com/azurelinux/base/python:3 COPY --from=0 /code/build/Linux/Release/dist /root COPY --from=0 /code/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt -RUN tdnf install -y ca-certificates python3-setuptools python3-wheel python3-pip python3-numpy python3-flatbuffers python3-packaging python3-protobuf python3-mpmath python3-sympy && python3 -m pip install coloredlogs humanfriendly && python3 -m pip install --no-index --find-links /root onnxruntime && rm -rf /root/*.whl +RUN tdnf install -y ca-certificates python3-setuptools python3-wheel python3-pip python3-numpy python3-flatbuffers python3-packaging python3-protobuf python3-mpmath python3-sympy && python3 -m pip install humanfriendly && python3 -m pip install --no-index --find-links /root onnxruntime && rm -rf /root/*.whl diff --git a/docs/python/requirements.txt b/docs/python/requirements.txt index 0be11c8760892..0b0e5d464b26e 100644 --- a/docs/python/requirements.txt +++ b/docs/python/requirements.txt @@ -11,7 +11,6 @@ furo pyquickhelper pandas pydot -coloredlogs flatbuffers numpy<2.0.0 packaging diff --git a/onnxruntime/python/tools/tensorrt/perf/benchmark.py b/onnxruntime/python/tools/tensorrt/perf/benchmark.py index 66ab0c44f8814..2017cf154f21e 100644 --- a/onnxruntime/python/tools/tensorrt/perf/benchmark.py +++ b/onnxruntime/python/tools/tensorrt/perf/benchmark.py @@ -12,7 +12,6 @@ import timeit from datetime import datetime -import coloredlogs import numpy as np from perf_utils import ( acl, @@ -2259,12 +2258,13 @@ def parse_arguments(): def setup_logger(verbose): if verbose: - coloredlogs.install( - level="DEBUG", - fmt="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + logging.basicConfig( + level=logging.DEBUG, + format="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + force=True, ) else: - coloredlogs.install(fmt="%(message)s") + logging.basicConfig(format="%(message)s", force=True) logging.getLogger("transformers").setLevel(logging.WARNING) diff --git a/onnxruntime/python/tools/tensorrt/perf/benchmark_wrapper.py b/onnxruntime/python/tools/tensorrt/perf/benchmark_wrapper.py index 204fe61396663..7bfe25b1549cf 100644 --- a/onnxruntime/python/tools/tensorrt/perf/benchmark_wrapper.py +++ b/onnxruntime/python/tools/tensorrt/perf/benchmark_wrapper.py @@ -11,7 +11,6 @@ import pprint import re -import coloredlogs # noqa: F401 from benchmark import * # noqa: F403 from perf_utils import * # noqa: F403 diff --git a/onnxruntime/python/tools/tensorrt/perf/perf_utils.py b/onnxruntime/python/tools/tensorrt/perf/perf_utils.py index 8d2f4b07b7984..4b83e1a8fc41f 100644 --- a/onnxruntime/python/tools/tensorrt/perf/perf_utils.py +++ b/onnxruntime/python/tools/tensorrt/perf/perf_utils.py @@ -5,8 +5,6 @@ import subprocess import sys -import coloredlogs # noqa: F401 - debug = False debug_verbose = False diff --git a/onnxruntime/python/tools/tensorrt/perf/requirements.txt b/onnxruntime/python/tools/tensorrt/perf/requirements.txt index 0afbf47e88307..2a4b319cfc57e 100644 --- a/onnxruntime/python/tools/tensorrt/perf/requirements.txt +++ b/onnxruntime/python/tools/tensorrt/perf/requirements.txt @@ -1,4 +1,3 @@ onnxconverter-common onnxmltools pandas -coloredlogs \ No newline at end of file diff --git a/onnxruntime/python/tools/transformers/benchmark_helper.py b/onnxruntime/python/tools/transformers/benchmark_helper.py index 8055e5e4ae876..56b670e8f2306 100644 --- a/onnxruntime/python/tools/transformers/benchmark_helper.py +++ b/onnxruntime/python/tools/transformers/benchmark_helper.py @@ -18,7 +18,6 @@ from time import sleep from typing import Any -import coloredlogs import numpy import torch import transformers @@ -147,12 +146,12 @@ def create_onnxruntime_session( def setup_logger(verbose=True): if verbose: - coloredlogs.install( - level="DEBUG", - fmt="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + logging.basicConfig( + format="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + level=logging.DEBUG, ) else: - coloredlogs.install(fmt="%(message)s") + logging.basicConfig(format="%(message)s", level=logging.INFO) logging.getLogger("transformers").setLevel(logging.WARNING) diff --git a/onnxruntime/python/tools/transformers/convert_to_packing_mode.py b/onnxruntime/python/tools/transformers/convert_to_packing_mode.py index 9a6388b3f350d..d8177fcd3cb02 100644 --- a/onnxruntime/python/tools/transformers/convert_to_packing_mode.py +++ b/onnxruntime/python/tools/transformers/convert_to_packing_mode.py @@ -7,7 +7,6 @@ import logging import os -import coloredlogs from constants import ( AttentionInputIDs, AttentionOutputIDs, @@ -358,12 +357,12 @@ def _parse_arguments(): def _setup_logger(verbose): if verbose: - coloredlogs.install( - level="DEBUG", - fmt="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + logging.basicConfig( + format="[%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s", + level=logging.DEBUG, ) else: - coloredlogs.install(fmt="%(funcName)20s: %(message)s") + logging.basicConfig(format="%(funcName)20s: %(message)s", level=logging.INFO) def main(): diff --git a/onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.py b/onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.py index 21848deaf99fe..674dc831d70f9 100644 --- a/onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.py +++ b/onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.py @@ -11,7 +11,7 @@ # conda create -n gpu_env python=3.8 # conda activate gpu_env # pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -# pip3 install onnx transformers onnxruntime-gpu numpy sympy coloredlogs psutil py3nvml +# pip3 install onnx transformers onnxruntime-gpu numpy sympy psutil py3nvml # python benchmark_longformer.py # # When there is no parameter, pre-defined tests will run on the longformer-base-4096 model. diff --git a/onnxruntime/python/tools/transformers/models/longformer/convert_to_onnx.py b/onnxruntime/python/tools/transformers/models/longformer/convert_to_onnx.py index b80feec892994..513a115352556 100644 --- a/onnxruntime/python/tools/transformers/models/longformer/convert_to_onnx.py +++ b/onnxruntime/python/tools/transformers/models/longformer/convert_to_onnx.py @@ -18,7 +18,7 @@ # conda create -n longformer python=3.8 # conda activate longformer # python3 -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html -# python3 -m pip install coloredlogs flatbuffers numpy packaging sympy protobuf==3.20.1 onnx==1.12.0 transformers==4.18.0 +# python3 -m pip install flatbuffers numpy packaging sympy protobuf==3.20.1 onnx==1.12.0 transformers==4.18.0 # python3 -m pip install -i https://test.pypi.org/simple/ ort-nightly-gpu # cd ./torch_extensions # rm -rf build diff --git a/onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py b/onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py index ed2e346972a6c..e90af970032e5 100755 --- a/onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py +++ b/onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py @@ -5,14 +5,13 @@ import argparse import csv +import logging import os import statistics import sys import time from pathlib import Path -import coloredlogs - # import torch before onnxruntime so that onnxruntime uses the cuDNN in the torch package. import torch from benchmark_helper import measure_memory @@ -1332,7 +1331,7 @@ def main(): if version.parse(ort_version) < version.parse("1.16"): raise ValueError("CUDA graph requires ONNX Runtime 1.16 or later") - coloredlogs.install(fmt="%(funcName)20s: %(message)s") + logging.basicConfig(format="%(funcName)20s: %(message)s", level=logging.INFO, force=True) memory_monitor_type = "cuda" diff --git a/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img.py b/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img.py index a3caba138f44a..d851e785e8d84 100644 --- a/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img.py +++ b/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img.py @@ -20,7 +20,8 @@ # limitations under the License. # -------------------------------------------------------------------------- -import coloredlogs +import logging + from cuda import cudart from demo_utils import ( add_controlnet_arguments, @@ -86,7 +87,7 @@ def run_inference(warmup=False): if __name__ == "__main__": - coloredlogs.install(fmt="%(funcName)20s: %(message)s") + logging.basicConfig(format="%(funcName)20s: %(message)s", level=logging.INFO) parser = arg_parser("Options for Stable Diffusion Demo") add_controlnet_arguments(parser) diff --git a/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py b/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py index c3e91a405b53f..739f3cb5025e7 100644 --- a/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py +++ b/onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py @@ -20,7 +20,8 @@ # limitations under the License. # -------------------------------------------------------------------------- -import coloredlogs +import logging + from cuda import cudart from demo_utils import ( add_controlnet_arguments, @@ -252,7 +253,7 @@ def main(args): if __name__ == "__main__": - coloredlogs.install(fmt="%(funcName)20s: %(message)s") + logging.basicConfig(format="%(funcName)20s: %(message)s", level=logging.INFO) parser = arg_parser("Options for Stable Diffusion XL Demo") add_controlnet_arguments(parser) diff --git a/onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py b/onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py index eb4d7242f72fc..a2c5d190824af 100644 --- a/onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py +++ b/onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py @@ -22,7 +22,6 @@ import tempfile from pathlib import Path -import coloredlogs import onnx from fusion_options import FusionOptions from onnx_model_clip import ClipOnnxModel @@ -580,5 +579,5 @@ def main(argv: list[str] | None = None): if __name__ == "__main__": - coloredlogs.install(fmt="%(funcName)20s: %(message)s") + logging.basicConfig(format="%(funcName)20s: %(message)s", level=logging.INFO) main() diff --git a/onnxruntime/python/tools/transformers/models/stable_diffusion/requirements/requirements.txt b/onnxruntime/python/tools/transformers/models/stable_diffusion/requirements/requirements.txt index 73929214b22ea..e7852f7478db8 100644 --- a/onnxruntime/python/tools/transformers/models/stable_diffusion/requirements/requirements.txt +++ b/onnxruntime/python/tools/transformers/models/stable_diffusion/requirements/requirements.txt @@ -4,7 +4,6 @@ transformers==4.50.0 numpy>=1.24.1 accelerate onnx==1.18.0 -coloredlogs packaging # Use newer version of protobuf might cause crash protobuf==4.25.8 diff --git a/onnxruntime/python/tools/transformers/notebooks/Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb b/onnxruntime/python/tools/transformers/notebooks/Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb index 5e81e754e1109..6603c9c387517 100644 --- a/onnxruntime/python/tools/transformers/notebooks/Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb +++ b/onnxruntime/python/tools/transformers/notebooks/Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb @@ -52,7 +52,7 @@ "else:\n", " !{sys.executable} -m pip install install torch --index-url https://download.pytorch.org/whl/cpu -q\n", "\n", - "!{sys.executable} -m pip install onnxruntime transformers==4.18 onnx psutil pandas py-cpuinfo py3nvml netron coloredlogs --no-warn-script-location -q" + "!{sys.executable} -m pip install onnxruntime transformers==4.18 onnx psutil pandas py-cpuinfo py3nvml netron --no-warn-script-location -q" ] }, { @@ -719,4 +719,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/onnxruntime/python/tools/transformers/notebooks/PyTorch_Bert-Squad_OnnxRuntime_GPU.ipynb b/onnxruntime/python/tools/transformers/notebooks/PyTorch_Bert-Squad_OnnxRuntime_GPU.ipynb index 7295ae1436c99..76458ca3220c9 100644 --- a/onnxruntime/python/tools/transformers/notebooks/PyTorch_Bert-Squad_OnnxRuntime_GPU.ipynb +++ b/onnxruntime/python/tools/transformers/notebooks/PyTorch_Bert-Squad_OnnxRuntime_GPU.ipynb @@ -59,7 +59,7 @@ "\n", "if sys.platform in ['linux', 'win32']: # Linux or Windows\n", " !{sys.executable} -m pip install torch --index-url https://download.pytorch.org/whl/cu118 -q\n", - " !{sys.executable} -m pip install onnxruntime-gpu onnx transformers psutil pandas py-cpuinfo py3nvml coloredlogs wget netron sympy protobuf==3.20.3 -q\n", + " !{sys.executable} -m pip install onnxruntime-gpu onnx transformers psutil pandas py-cpuinfo py3nvml wget netron sympy protobuf==3.20.3 -q\n", "else: # Mac\n", " print(\"CUDA is not available on MacOS\")" ] @@ -196,9 +196,9 @@ "Some weights of the model checkpoint at bert-large-uncased-whole-word-masking-finetuned-squad were not used when initializing BertForQuestionAnswering: ['bert.pooler.dense.bias', 'bert.pooler.dense.weight']\n", "- This IS expected if you are initializing BertForQuestionAnswering from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n", "- This IS NOT expected if you are initializing BertForQuestionAnswering from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n", - "100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 48/48 [00:02<00:00, 16.27it/s]\n", - "convert squad examples to features: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [00:03<00:00, 256.11it/s]\n", - "add example index and unique id: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [00:00= 1.8 numpy >= 1.19.0 -coloredlogs psutil py-cpuinfo py3nvml diff --git a/onnxruntime/python/tools/transformers/run_benchmark.sh b/onnxruntime/python/tools/transformers/run_benchmark.sh index 25997f40d348f..c16d60d0d5046 100755 --- a/onnxruntime/python/tools/transformers/run_benchmark.sh +++ b/onnxruntime/python/tools/transformers/run_benchmark.sh @@ -95,7 +95,7 @@ if [ "$run_install" = true ] ; then else pip install onnxruntime-gpu fi - pip install --upgrade onnx coloredlogs packaging psutil py3nvml numpy transformers sympy + pip install --upgrade onnx packaging psutil py3nvml numpy transformers sympy fi if [ "$use_package" = true ] ; then diff --git a/onnxruntime/test/python/transformers/test_gpt2_benchmark.py b/onnxruntime/test/python/transformers/test_gpt2_benchmark.py index 2d9bc035fe4fd..40be872250f1a 100644 --- a/onnxruntime/test/python/transformers/test_gpt2_benchmark.py +++ b/onnxruntime/test/python/transformers/test_gpt2_benchmark.py @@ -9,7 +9,6 @@ import os import unittest -import coloredlogs import pytest from parity_utilities import find_transformers_source @@ -50,6 +49,6 @@ def test_gpt2_int8(self): if __name__ == "__main__": - coloredlogs.install(fmt="%(message)s") + logging.basicConfig(format="%(message)s") logging.getLogger("transformers").setLevel(logging.ERROR) unittest.main() diff --git a/onnxruntime/test/python/transformers/test_gpt2_to_onnx.py b/onnxruntime/test/python/transformers/test_gpt2_to_onnx.py index e179d3d087120..bda99abbb7287 100644 --- a/onnxruntime/test/python/transformers/test_gpt2_to_onnx.py +++ b/onnxruntime/test/python/transformers/test_gpt2_to_onnx.py @@ -7,7 +7,6 @@ import logging import unittest -import coloredlogs import pytest from parity_utilities import find_transformers_source @@ -58,6 +57,6 @@ def test_auto_mixed_precision(self): if __name__ == "__main__": - coloredlogs.install(fmt="%(message)s") + logging.basicConfig(format="%(message)s") logging.getLogger("transformers").setLevel(logging.ERROR) unittest.main() diff --git a/requirements.txt b/requirements.txt index 2fd9362c949dd..ff8cc04d6f219 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -coloredlogs flatbuffers numpy >= 1.21.6 packaging diff --git a/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-daily-perf-pipeline.yml b/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-daily-perf-pipeline.yml index c00cbb06f26fd..4bfb9c630fede 100644 --- a/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-daily-perf-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/linux-gpu-tensorrt-daily-perf-pipeline.yml @@ -142,7 +142,7 @@ jobs: workingDirectory: '$(Build.SourcesDirectory)/onnxruntime/python/tools/tensorrt/perf/' condition: always() - - script: 'python3 -m pip install pandas azure-kusto-data[pandas] azure-kusto-ingest[pandas] coloredlogs' + - script: 'python3 -m pip install pandas azure-kusto-data[pandas] azure-kusto-ingest[pandas]' displayName: 'Install dashboard dependencies' - script: | @@ -165,7 +165,7 @@ jobs: - ${{ if eq(parameters.PostToDashboard, true) }}: - - script: 'python3 -m pip install pandas azure-kusto-data[pandas] azure-kusto-ingest[pandas] coloredlogs' + - script: 'python3 -m pip install pandas azure-kusto-data[pandas] azure-kusto-ingest[pandas]' displayName: 'Install dashboard dependencies' - script: | @@ -191,4 +191,4 @@ jobs: pathtoPublish: '$(Build.SourcesDirectory)/Artifact' artifactName: 'result-$(Build.BuildNumber)' - - template: templates/clean-agent-build-directory-step.yml \ No newline at end of file + - template: templates/clean-agent-build-directory-step.yml diff --git a/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml b/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml index 9b15f389e5349..4ec074055fcc2 100644 --- a/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml +++ b/tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml @@ -54,7 +54,7 @@ jobs: FILE_NAME="${files[0]}" FILE_NAME=$(basename $FILE_NAME) PYTHON_PACKAGE_NAME=$(echo "$FILE_NAME" | cut -f 1 -d '-') - python3 -m pip install coloredlogs flatbuffers numpy packaging protobuf sympy + python3 -m pip install flatbuffers numpy packaging protobuf sympy python3 -m pip install --no-index --find-links . $PYTHON_PACKAGE_NAME python3 -m pip show $PYTHON_PACKAGE_NAME python3 -c "import onnxruntime as ort; print(ort.__version__)" diff --git a/tools/ci_build/github/windows/python/requirements.txt b/tools/ci_build/github/windows/python/requirements.txt index 4e24bf7cbfa97..a86eef170bc25 100644 --- a/tools/ci_build/github/windows/python/requirements.txt +++ b/tools/ci_build/github/windows/python/requirements.txt @@ -14,5 +14,4 @@ jinja2 markupsafe semver packaging -coloredlogs onnx==1.20.1; python_version < "3.14" diff --git a/tools/ci_build/requirements/transformers-test/requirements.txt b/tools/ci_build/requirements/transformers-test/requirements.txt index e95509c7ddec3..1523b420bfdbd 100644 --- a/tools/ci_build/requirements/transformers-test/requirements.txt +++ b/tools/ci_build/requirements/transformers-test/requirements.txt @@ -6,7 +6,6 @@ numpy==2.2.6; python_version < "3.14" numpy==2.3.2; python_version >= "3.14" torch==2.8.0 torchvision==0.23.0 -coloredlogs==15.0 transformers==4.52.1 parameterized>=0.8.1 sentencepiece