From d834e8b5b3d8be4b979bd1df1d96f684786b447b Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 18 Dec 2023 20:34:32 -0800 Subject: [PATCH] test: run non-gpu tests on github --- .github/workflows/ci.yaml | 41 ++++++++++++++++++++++------- .gitignore | 2 ++ tests/conftest.py | 6 ++--- tests/data/cuda-tests.csv | 54 ++++++++++++++++++++++++++++++++++++++ tests/test_feather_tile.py | 3 +++ 5 files changed, 93 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53bbd72..101bb62 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,10 @@ on: env: PIP_DISABLE_PIP_VERSION_CHECK: 1 +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest @@ -48,31 +52,50 @@ jobs: - name: Lint run: | black --diff --fast . - test: - runs-on: ${{ matrix.os }} + test-gpu: + runs-on: nvidia-4090 + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" +# cache: pip +# cache-dependency-path: requirements-dev.txt + - name: Install dependencies + run: | + python -m pip uninstall torch torchvision xformers triton imaginairy -y + python -m pip install -r requirements-dev.in . --upgrade + - name: Test with pytest + timeout-minutes: 30 + env: + CUDA_LAUNCH_BLOCKING: 1 + run: | + pytest --durations=10 -v -m "gputest" + test-non-gpu: + runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.10"] - os: ["nvidia-4090"] + os: ["ubuntu-latest"] steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} -# cache: pip -# cache-dependency-path: requirements-dev.txt + python-version: "3.10" + cache: pip + cache-dependency-path: requirements-dev.txt - name: Install dependencies run: | - python -m pip uninstall torch torchvision xformers triton imaginairy -y python -m pip install -r requirements-dev.in . --upgrade - name: Test with pytest timeout-minutes: 30 env: CUDA_LAUNCH_BLOCKING: 1 run: | - pytest --durations=10 -v + pytest --durations=10 -v -m "not gputest" type-check: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index ed9b55a..6423ed0 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ tests/vastai_cli.py /img_size_memory_usage.csv /tests/test_cluster_output/ /.env +*.ipynb +.ipynb_checkpoints \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 6858a6f..84e0678 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -152,8 +152,8 @@ def detect_cuda_tests(request): print(f"Test {test_id} used {memory_diff} bytes of GPU memory") cuda_tests_node_ids.append(test_id) - torch.cuda.empty_cache() - gc.collect() + torch.cuda.empty_cache() + gc.collect() @pytest.hookimpl() @@ -162,9 +162,7 @@ def pytest_collection_modifyitems(config, items): node_ids_to_mark = read_stored_cuda_test_nodes() for item in items: - print(item.nodeid) if item.nodeid in node_ids_to_mark: - print(f"Marking {item.nodeid} as gputest") item.add_marker(pytest.mark.gputest) filtered_node_ids = set() diff --git a/tests/data/cuda-tests.csv b/tests/data/cuda-tests.csv index a21a2f0..94254cd 100644 --- a/tests/data/cuda-tests.csv +++ b/tests/data/cuda-tests.csv @@ -1 +1,55 @@ +tests/img_processors/test_control_modes.py::test_control_images[depth-create_depth_map] +tests/img_processors/test_control_modes.py::test_control_images[hed-create_hed_edges] +tests/img_processors/test_control_modes.py::test_control_images[normal-create_normal_map] +tests/img_processors/test_control_modes.py::test_control_images[openpose-create_pose_map] +tests/img_processors/test_control_modes.py::test_control_images[qrcode-adaptive_threshold_binarize] +tests/modules/diffusion/test_model.py::test_nonlinearity +tests/test_api.py::test_cliptext_inpainting_pearl_doctor +tests/test_api.py::test_controlnet[canny] +tests/test_api.py::test_controlnet[colorize] +tests/test_api.py::test_controlnet[depth] +tests/test_api.py::test_controlnet[details] +tests/test_api.py::test_controlnet[edit] +tests/test_api.py::test_controlnet[hed] +tests/test_api.py::test_controlnet[inpaint] +tests/test_api.py::test_controlnet[normal] +tests/test_api.py::test_controlnet[openpose] +tests/test_api.py::test_controlnet[qrcode] +tests/test_api.py::test_controlnet[shuffle] +tests/test_api.py::test_imagine[ddim] +tests/test_api.py::test_imagine[dpmpp] +tests/test_api.py::test_img2img_beach_to_sunset[ddim] +tests/test_api.py::test_img2img_beach_to_sunset[dpmpp] +tests/test_api.py::test_img2img_low_noise[ddim] +tests/test_api.py::test_img2img_low_noise[dpmpp] +tests/test_api.py::test_img_to_file +tests/test_api.py::test_img_to_img_from_url_cats[ddim] +tests/test_api.py::test_img_to_img_from_url_cats[dpmpp] +tests/test_api.py::test_img_to_img_fruit_2_gold[ddim-0.05] +tests/test_api.py::test_img_to_img_fruit_2_gold[ddim-0.2] +tests/test_api.py::test_img_to_img_fruit_2_gold[ddim-0] +tests/test_api.py::test_img_to_img_fruit_2_gold[ddim-1] +tests/test_api.py::test_img_to_img_fruit_2_gold[dpmpp-0.05] +tests/test_api.py::test_img_to_img_fruit_2_gold[dpmpp-0.2] +tests/test_api.py::test_img_to_img_fruit_2_gold[dpmpp-0] +tests/test_api.py::test_img_to_img_fruit_2_gold[dpmpp-1] +tests/test_api.py::test_img_to_img_fruit_2_gold_repeat +tests/test_api.py::test_inpainting_bench +tests/test_api.py::test_large_image +tests/test_api.py::test_model_versions[SD-1.5] +tests/test_api.py::test_tile_mode +tests/test_cli/test_cmds.py::test_colorize_cmd +tests/test_cli/test_cmds.py::test_describe_cmd +tests/test_cli/test_cmds.py::test_edit_cmd +tests/test_cli/test_cmds.py::test_edit_demo +tests/test_cli/test_cmds.py::test_imagine_cmd +tests/test_clip_embedder.py::test_text_conditioning +tests/test_enhancers.py::test_clip_masking +tests/test_enhancers.py::test_clip_text_comparison +tests/test_enhancers.py::test_describe_picture +tests/test_enhancers.py::test_fix_faces tests/test_outpaint.py::test_outpainting_outpaint +tests/test_safety.py::test_is_nsfw +tests/test_utils/test_model_cache.py::test_cache_ordering +tests/test_utils/test_model_cache.py::test_get_existing_move_to_gpu +tests/test_utils/test_model_cache.py::test_set_cpu_full diff --git a/tests/test_feather_tile.py b/tests/test_feather_tile.py index 9541b53..a43516b 100644 --- a/tests/test_feather_tile.py +++ b/tests/test_feather_tile.py @@ -78,6 +78,9 @@ def test_feather_tile_simple(img_ratio, tile_size, overlap_pct): assert diff < 1 +@pytest.mark.skip( + reason="takes too long. runs 5000 scenarios. if you mess with feather_tile, run this test" +) def test_feather_tile_brute(): source_img = pillow_img_to_torch_image( LazyLoadingImage(filepath=f"{TESTS_FOLDER}/data/bowl_of_fruit.jpg")