Separate GPU CI job in actions (#4584)

pull/4590/head
Glenn Jocher 1 year ago committed by GitHub
parent f755ba88c3
commit c635418a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 47
      .github/workflows/ci.yaml
  2. 2
      docker/Dockerfile
  3. 16
      docs/datasets/segment/index.md
  4. 13
      tests/test_python.py

@ -24,6 +24,10 @@ on:
description: 'Run Benchmarks'
default: false
type: boolean
gpu:
description: 'Run GPU'
default: false
type: boolean
jobs:
HUB:
@ -47,6 +51,7 @@ jobs:
pip install -e . --extra-index-url https://download.pytorch.org/whl/cpu
- name: Check environment
run: |
yolo checks
echo "RUNNER_OS is ${{ runner.os }}"
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
@ -110,6 +115,7 @@ jobs:
yolo export format=tflite imgsz=32 || true
- name: Check environment
run: |
yolo checks
echo "RUNNER_OS is ${{ runner.os }}"
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
@ -159,7 +165,6 @@ jobs:
- os: ubuntu-latest
python-version: '3.8' # torch 1.8.0 requires python >=3.6, <=3.8
torch: '1.8.0' # min torch version CI https://pypi.org/project/torchvision/
- os: gpu-latest # do not pass python-version
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
@ -189,12 +194,7 @@ jobs:
pip list
- name: Pytest tests
shell: bash # for Windows compatibility
run: |
if [ "${{ matrix.os }}" == "gpu-latest" ]; then
pytest --cov=ultralytics/ --cov-report xml tests/test_cuda.py
else
pytest --cov=ultralytics/ --cov-report xml tests/
fi
run: pytest --cov=ultralytics/ --cov-report xml tests/
- name: Upload Coverage Reports to CodeCov
if: github.repository == 'ultralytics/ultralytics' # && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
@ -203,13 +203,42 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GPU:
if: github.repository == 'ultralytics/ultralytics' && (github.event_name != 'workflow_dispatch' || github.event.inputs.gpu == 'true')
timeout-minutes: 60
runs-on: gpu-latest
steps:
- uses: actions/checkout@v3
- name: Install requirements
run: pip install -e .
- name: Check environment
run: |
yolo checks
echo "RUNNER_OS is ${{ runner.os }}"
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}"
echo "GITHUB_WORKFLOW is ${{ github.workflow }}"
echo "GITHUB_ACTOR is ${{ github.actor }}"
echo "GITHUB_REPOSITORY is ${{ github.repository }}"
echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}"
python --version
pip --version
pip list
- name: Pytest tests
run: pytest --cov=ultralytics/ --cov-report xml tests/test_cuda.py
- name: Upload Coverage Reports to CodeCov
uses: codecov/codecov-action@v3
with:
flags: GPU
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Summary:
runs-on: ubuntu-latest
needs: [HUB, Benchmarks, Tests] # Add job names that you want to check for failure
needs: [HUB, Benchmarks, Tests, GPU] # Add job names that you want to check for failure
if: always() # This ensures the job runs even if previous jobs fail
steps:
- name: Check for failure and notify
if: (needs.HUB.result == 'failure' || needs.Benchmarks.result == 'failure' || needs.Tests.result == 'failure') && github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push')
if: (needs.HUB.result == 'failure' || needs.Benchmarks.result == 'failure' || needs.Tests.result == 'failure' || needs.GPU.result == 'failure') && github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push')
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |

@ -29,7 +29,7 @@ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt /u
# Install pip packages
RUN python3 -m pip install --upgrade pip wheel
RUN pip install --no-cache -e ".[export]" thop albumentations comet pycocotools
RUN pip install --no-cache -e ".[export]" thop albumentations comet pycocotools pytest-cov
# Run exports to AutoInstall packages
RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32

@ -133,13 +133,15 @@ To auto-annotate your dataset using the Ultralytics framework, you can use the `
auto_annotate(data="path/to/images", det_model="yolov8x.pt", sam_model='sam_b.pt')
```
| Argument | Type | Description | Default |
|------------|---------------------|---------------------------------------------------------------------------------------------------------|--------------|
| data | str | Path to a folder containing images to be annotated. | |
| det_model | str, optional | Pre-trained YOLO detection model. Defaults to 'yolov8x.pt'. | 'yolov8x.pt' |
| sam_model | str, optional | Pre-trained SAM segmentation model. Defaults to 'sam_b.pt'. | 'sam_b.pt' |
| device | str, optional | Device to run the models on. Defaults to an empty string (CPU or GPU, if available). | |
| output_dir | str, None, optional | Directory to save the annotated results. Defaults to a 'labels' folder in the same directory as 'data'. | None |
Certainly, here is the table updated with code snippets:
| Argument | Type | Description | Default |
|--------------|-------------------------|-------------------------------------------------------------------------------------------------------------|----------------|
| `data` | `str` | Path to a folder containing images to be annotated. | `None` |
| `det_model` | `str, optional` | Pre-trained YOLO detection model. Defaults to `'yolov8x.pt'`. | `'yolov8x.pt'` |
| `sam_model` | `str, optional` | Pre-trained SAM segmentation model. Defaults to `'sam_b.pt'`. | `'sam_b.pt'` |
| `device` | `str, optional` | Device to run the models on. Defaults to an empty string (CPU or GPU, if available). | `''` |
| `output_dir` | `str or None, optional` | Directory to save the annotated results. Defaults to a `'labels'` folder in the same directory as `'data'`. | `None` |
The `auto_annotate` function takes the path to your images, along with optional arguments for specifying the pre-trained detection and [SAM segmentation models](https://docs.ultralytics.com/models/sam), the device to run the models on, and the output directory for saving the annotated results.

@ -13,6 +13,7 @@ from PIL import Image
from torchvision.transforms import ToTensor
from ultralytics import RTDETR, YOLO
from ultralytics.cfg import TASK2DATA
from ultralytics.data.build import load_inference_source
from ultralytics.utils import ASSETS, DEFAULT_CFG, LINUX, ONLINE, ROOT, SETTINGS, WINDOWS
from ultralytics.utils.downloads import download
@ -275,11 +276,13 @@ def test_data_utils():
# from ultralytics.utils.files import WorkingDirectory
# with WorkingDirectory(ROOT.parent / 'tests'):
download('https://github.com/ultralytics/hub/raw/main/example_datasets/coco8.zip', unzip=False)
shutil.move('coco8.zip', TMP)
stats = HUBDatasetStats(TMP / 'coco8.zip', task='detect')
stats.get_json(save=True)
stats.process_images()
for task in 'detect', 'segment', 'pose':
file = Path(TASK2DATA[task]).with_suffix('.zip') # i.e. coco8.zip
download(f'https://github.com/ultralytics/hub/raw/main/example_datasets/{file}', unzip=False)
shutil.move(str(file), TMP) # Python 3.8 requires string input to shutil.move()
stats = HUBDatasetStats(TMP / file, task=task)
stats.get_json(save=True)
stats.process_images()
autosplit(TMP / 'coco8')
zip_directory(TMP / 'coco8/images/val') # zip

Loading…
Cancel
Save