Unverified Commit c52a33a1 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Skip some CPU-only tests on CircleCI machines with GPU (#4002)

parent ea6be124
......@@ -687,12 +687,20 @@ jobs:
paths:
- conda
- env
- run:
# Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
# Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
# They're avaiable in all the other workflows (OSX and Windows).
# But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
# So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
name: export CIRCLECI env var
command: echo "CIRCLECI=true" >> ./env.list
- run:
name: Install torchvision
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh
- run:
name: Run tests
command: docker run -e CIRCLECI -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
- run:
name: Post Process
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/post_process.sh
......
......@@ -687,12 +687,20 @@ jobs:
paths:
- conda
- env
- run:
# Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
# Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
# They're avaiable in all the other workflows (OSX and Windows).
# But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
# So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
name: export CIRCLECI env var
command: echo "CIRCLECI=true" >> ./env.list
- run:
name: Install torchvision
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh
- run:
name: Run tests
command: docker run -e CIRCLECI -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
- run:
name: Post Process
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/post_process.sh
......
......@@ -26,6 +26,7 @@ IN_CIRCLE_CI = os.getenv("CIRCLECI", False) == 'true'
IN_RE_WORKER = os.environ.get("INSIDE_RE_WORKER") is not None
IN_FBCODE = os.environ.get("IN_FBCODE_TORCHVISION") == "1"
CUDA_NOT_AVAILABLE_MSG = 'CUDA device not available'
CIRCLECI_GPU_NO_CUDA_MSG = "We're in a CircleCI GPU machine, and this test doesn't need cuda."
@contextlib.contextmanager
......@@ -256,11 +257,19 @@ def call_args_to_kwargs_only(call_args, *callable_or_arg_names):
def cpu_and_gpu():
# TODO: make this properly handle CircleCI
import pytest # noqa
# ignore CPU tests in RE as they're already covered by another contbuild
devices = [] if IN_RE_WORKER else ['cpu']
# also ignore CPU tests in CircleCI machines that have a GPU: these tests
# are run on CPU-only machines already.
if IN_RE_WORKER:
devices = []
else:
if IN_CIRCLE_CI and torch.cuda.is_available():
mark = pytest.mark.skip(reason=CIRCLECI_GPU_NO_CUDA_MSG)
else:
mark = ()
devices = [pytest.param('cpu', marks=mark)]
if torch.cuda.is_available():
cuda_marks = ()
......@@ -278,7 +287,6 @@ def cpu_and_gpu():
def needs_cuda(test_func):
# TODO: make this properly handle CircleCI
import pytest # noqa
if IN_FBCODE and not IN_RE_WORKER:
......@@ -293,12 +301,13 @@ def needs_cuda(test_func):
def cpu_only(test_func):
# TODO: make this properly handle CircleCI
import pytest # noqa
if IN_RE_WORKER:
# The assumption is that all RE workers have GPUs.
return pytest.mark.dont_collect(test_func)
elif IN_CIRCLE_CI and torch.cuda.is_available():
return pytest.mark.skip(reason=CIRCLECI_GPU_NO_CUDA_MSG)(test_func)
else:
return test_func
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment