diff --git a/.circleci/config.yml b/.circleci/config.yml index fdb57af08f5..b46718858d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -80,7 +80,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-{{ checksum "setup.py" }} @@ -116,7 +116,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-{{ checksum "setup.py" }} @@ -147,7 +147,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,flax,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-{{ checksum "setup.py" }} @@ -183,7 +183,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,flax,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-{{ checksum "setup.py" }} @@ -213,7 +213,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,torch,testing,sentencepiece,speech,vision,timm] + - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-torch-{{ checksum "setup.py" }} @@ -248,7 +248,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,torch,testing,sentencepiece,speech,vision,timm] + - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-torch-{{ checksum "setup.py" }} @@ -277,7 +277,7 @@ jobs: - v0.4-tf-{{ checksum "setup.py" }} - v0.4-{{ checksum "setup.py" }} - run: pip install --upgrade pip - - run: pip install .[sklearn,tf-cpu,testing,sentencepiece] + - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech] - save_cache: key: v0.4-tf-{{ checksum "setup.py" }} paths: @@ -310,7 +310,7 @@ jobs: - v0.4-tf-{{ checksum "setup.py" }} - v0.4-{{ checksum "setup.py" }} - run: pip install --upgrade pip - - run: pip install .[sklearn,tf-cpu,testing,sentencepiece] + - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech] - save_cache: key: v0.4-tf-{{ checksum "setup.py" }} paths: @@ -338,7 +338,7 @@ jobs: - v0.4-flax-{{ checksum "setup.py" }} - v0.4-{{ checksum "setup.py" }} - run: pip install --upgrade pip - - run: sudo pip install .[flax,testing,sentencepiece] + - run: sudo pip install .[flax,testing,sentencepiece,flax-speech,vision] - save_cache: key: v0.4-flax-{{ checksum "setup.py" }} paths: @@ -371,7 +371,7 @@ jobs: - v0.4-flax-{{ checksum "setup.py" }} - v0.4-{{ checksum "setup.py" }} - run: pip install --upgrade pip - - run: sudo pip install .[flax,testing,sentencepiece] + - run: sudo pip install .[flax,testing,sentencepiece,vision,flax-speech] - save_cache: key: v0.4-flax-{{ checksum "setup.py" }} paths: @@ -401,7 +401,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-torch-{{ checksum "setup.py" }} @@ -437,7 +437,7 @@ jobs: - v0.4-{{ checksum "setup.py" }} - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - run: pip install --upgrade pip - - run: pip install .[sklearn,torch,testing,sentencepiece,speech,vision] + - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision] - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html - save_cache: key: v0.4-torch-{{ checksum "setup.py" }} diff --git a/.github/workflows/self-push.yml b/.github/workflows/self-push.yml index 3a755f22d12..f112f8b82da 100644 --- a/.github/workflows/self-push.yml +++ b/.github/workflows/self-push.yml @@ -33,7 +33,7 @@ jobs: apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git apt install -y libsndfile1-dev pip install --upgrade pip - pip install .[sklearn,testing,onnxruntime,sentencepiece,speech,vision,timm] + pip install .[sklearn,testing,onnxruntime,sentencepiece,torch-speech,vision,timm] - name: Launcher docker uses: actions/checkout@v2 @@ -78,6 +78,61 @@ jobs: name: run_all_tests_torch_gpu_test_reports path: reports + run_tests_flax_gpu: + runs-on: [self-hosted, docker-gpu, single-gpu] + container: + image: tensorflow/tensorflow:2.4.1-gpu + options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ + steps: + - name: Install dependencies + run: | + apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git + pip install --upgrade "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html + pip install --upgrade pip + pip install .[sklearn,testing,sentencepiece,flax,flax-speech,vision] + + - name: Launcher docker + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: NVIDIA-SMI + run: | + nvidia-smi + + - name: Are GPUs recognized by our DL frameworks + run: | + python -c "from jax.lib import xla_bridge; print('GPU available:', xla_bridge.get_backend().platform)" + python -c "import jax; print('Number of GPUs available:', len(jax.local_devices()))" + +# - name: Fetch the tests to run +# run: | +# python utils/tests_fetcher.py --diff_with_last_commit | tee test_preparation.txt + + - name: Report fetched tests + uses: actions/upload-artifact@v2 + with: + name: test_fetched + path: test_preparation.txt + + - name: Run all non-slow tests on GPU + run: | + python -m pytest -n 2 --dist=loadfile -v --make-reports=tests_flax_gpu +# if [ -f test_list.txt ]; then +# python -m pytest -n 2 --dist=loadfile -v --make-reports=tests_flax_gpu $(cat test_list.txt) +# fi + + - name: Failure short reports + if: ${{ failure() }} + run: cat reports/tests_flax_gpu_failures_short.txt + + - name: Test suite reports artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: run_all_tests_flax_gpu_test_reports + path: reports + # run_tests_tf_gpu: # runs-on: [self-hosted, docker-gpu, single-gpu] # timeout-minutes: 120 @@ -89,7 +144,7 @@ jobs: # run: | # apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git # pip install --upgrade pip -# pip install .[sklearn,testing,onnxruntime,sentencepiece] +# pip install .[sklearn,testing,onnxruntime,sentencepiece,tf-speech] # # - name: Launcher docker # uses: actions/checkout@v2 @@ -147,7 +202,7 @@ jobs: apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git apt install -y libsndfile1-dev pip install --upgrade pip - pip install .[sklearn,testing,onnxruntime,sentencepiece,speech,vision,timm] + pip install .[sklearn,testing,onnxruntime,sentencepiece,torch-speech,vision,timm] - name: Launcher docker uses: actions/checkout@v2 @@ -195,6 +250,61 @@ jobs: name: run_all_tests_torch_multi_gpu_test_reports path: reports + run_tests_flax_multi_gpu: + runs-on: [self-hosted, docker-gpu, multi-gpu] + container: + image: tensorflow/tensorflow:2.4.1-gpu + options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ + steps: + - name: Install dependencies + run: | + apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git + pip install --upgrade "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html + pip install --upgrade pip + pip install .[sklearn,testing,sentencepiece,flax,flax-speech,vision] + + - name: Launcher docker + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: NVIDIA-SMI + run: | + nvidia-smi + + - name: Are GPUs recognized by our DL frameworks + run: | + python -c "from jax.lib import xla_bridge; print('GPU available:', xla_bridge.get_backend().platform)" + python -c "import jax; print('Number of GPUs available:', len(jax.local_devices()))" + +# - name: Fetch the tests to run +# run: | +# python utils/tests_fetcher.py --diff_with_last_commit | tee test_preparation.txt + + - name: Report fetched tests + uses: actions/upload-artifact@v2 + with: + name: test_fetched + path: test_preparation.txt + + - name: Run all non-slow tests on GPU + run: | + python -m pytest -n 2 --dist=loadfile -v --make-reports=tests_flax_multi_gpu +# if [ -f test_list.txt ]; then +# python -m pytest -n 2 --dist=loadfile -v --make-reports=tests_flax_multi_gpu $(cat test_list.txt) +# fi + + - name: Failure short reports + if: ${{ failure() }} + run: cat reports/tests_flax_multi_gpu_failures_short.txt + + - name: Test suite reports artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: run_all_tests_flax_multi_gpu_test_reports + path: reports + # run_tests_tf_multi_gpu: # runs-on: [self-hosted, docker-gpu, multi-gpu] # timeout-minutes: 120 @@ -206,7 +316,7 @@ jobs: # run: | # apt -y update && apt install -y software-properties-common && apt -y update && add-apt-repository -y ppa:git-core/ppa && apt -y update && apt install -y git # pip install --upgrade pip -# pip install .[sklearn,testing,onnxruntime,sentencepiece] +# pip install .[sklearn,testing,onnxruntime,sentencepiece,tf-speech] # # - name: Launcher docker # uses: actions/checkout@v2 diff --git a/.github/workflows/self-scheduled.yml b/.github/workflows/self-scheduled.yml index a1ad79b4300..834653af9d0 100644 --- a/.github/workflows/self-scheduled.yml +++ b/.github/workflows/self-scheduled.yml @@ -34,7 +34,7 @@ jobs: run: | apt -y update && apt install -y libsndfile1-dev git pip install --upgrade pip - pip install .[integrations,sklearn,testing,onnxruntime,sentencepiece,speech,vision,timm] + pip install .[integrations,sklearn,testing,onnxruntime,sentencepiece,torch-speech,vision,timm] - name: Are GPUs recognized by our DL frameworks run: | @@ -85,6 +85,45 @@ jobs: name: run_all_tests_torch_gpu_test_reports path: reports + run_all_tests_flax_gpu: + runs-on: [self-hosted, docker-gpu, single-gpu] + container: + image: tensorflow/tensorflow:2.4.1-gpu + options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ + steps: + - name: Launcher docker + uses: actions/checkout@v2 + + - name: NVIDIA-SMI + run: | + nvidia-smi + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --upgrade "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html + pip install .[flax,integrations,sklearn,testing,sentencepiece,flax-speech,vision] + + - name: Are GPUs recognized by our DL frameworks + run: | + python -c "from jax.lib import xla_bridge; print('GPU available:', xla_bridge.get_backend().platform)" + python -c "import jax; print('Number of GPUs available:', len(jax.local_devices()))" + + - name: Run all tests on GPU + run: | + python -m pytest -n 1 -v --dist=loadfile --make-reports=tests_flax_gpu tests + + - name: Failure short reports + if: ${{ always() }} + run: cat reports/tests_flax_gpu_failures_short.txt + + - name: Test suite reports artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: run_all_tests_flax_gpu_test_reports + path: reports + run_all_tests_tf_gpu: runs-on: [self-hosted, docker-gpu, single-gpu] container: @@ -102,7 +141,7 @@ jobs: run: | apt -y update && apt install -y git pip install --upgrade pip - pip install .[sklearn,testing,onnx,sentencepiece] + pip install .[sklearn,testing,onnx,sentencepiece,tf-speech] - name: Are GPUs recognized by our DL frameworks run: | @@ -158,7 +197,7 @@ jobs: run: | apt -y update && apt install -y libsndfile1-dev git pip install --upgrade pip - pip install .[integrations,sklearn,testing,onnxruntime,sentencepiece,speech,vision,timm] + pip install .[integrations,sklearn,testing,onnxruntime,sentencepiece,torch-speech,vision,timm] - name: Are GPUs recognized by our DL frameworks run: | @@ -213,7 +252,7 @@ jobs: run: | apt -y update && apt install -y git pip install --upgrade pip - pip install .[sklearn,testing,onnx,sentencepiece] + pip install .[sklearn,testing,onnx,sentencepiece,tf-speech] - name: Are GPUs recognized by our DL frameworks run: | @@ -251,6 +290,45 @@ jobs: name: run_all_tests_tf_multi_gpu_test_reports path: reports + run_all_tests_flax_multi_gpu: + runs-on: [self-hosted, docker-gpu, multi-gpu] + container: + image: tensorflow/tensorflow:2.4.1-gpu + options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ + steps: + - name: Launcher docker + uses: actions/checkout@v2 + + - name: NVIDIA-SMI + run: | + nvidia-smi + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --upgrade "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html + pip install .[flax,integrations,sklearn,testing,sentencepiece,flax-speech,vision] + + - name: Are GPUs recognized by our DL frameworks + run: | + python -c "from jax.lib import xla_bridge; print('GPU available:', xla_bridge.get_backend().platform)" + python -c "import jax; print('Number of GPUs available:', len(jax.local_devices()))" + + - name: Run all tests on GPU + run: | + python -m pytest -n 1 -v --dist=loadfile --make-reports=tests_flax_gpu tests + + - name: Failure short reports + if: ${{ always() }} + run: cat reports/tests_flax_gpu_failures_short.txt + + - name: Test suite reports artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: run_all_tests_flax_gpu_test_reports + path: reports + run_all_tests_torch_cuda_extensions_gpu: runs-on: [self-hosted, docker-gpu, single-gpu] container: diff --git a/setup.py b/setup.py index f7e28b2f5d4..a797c163827 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright 2020 The HuggingFace Team. All rights reserved. +# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -64,7 +64,6 @@ from pathlib import Path from setuptools import find_packages, setup - # Remove stale transformers.egg-info directory to avoid https://github.com/pypa/pip/issues/5466 stale_egg_info = Path(__file__).parent / "transformers.egg-info" if stale_egg_info.exists(): @@ -253,7 +252,11 @@ extras["ray"] = deps_list("ray[tune]") extras["integrations"] = extras["optuna"] + extras["ray"] extras["serving"] = deps_list("pydantic", "uvicorn", "fastapi", "starlette") -extras["speech"] = deps_list("soundfile", "torchaudio") +extras["audio"] = deps_list("soundfile") +extras["speech"] = deps_list("torchaudio") + extras["audio"] # `pip install ".[speech]"` is deprecated and `pip install ".[torch-speech]"` should be used instead +extras["torch-speech"] = deps_list("torchaudio") + extras["audio"] +extras["tf-speech"] = extras["audio"] +extras["flax-speech"] = extras["audio"] extras["vision"] = deps_list("Pillow") extras["timm"] = deps_list("timm") extras["codecarbon"] = deps_list("codecarbon") @@ -275,7 +278,7 @@ extras["all"] = ( + extras["flax"] + extras["sentencepiece"] + extras["tokenizers"] - + extras["speech"] + + extras["torch-speech"] + extras["vision"] + extras["integrations"] + extras["timm"]