diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index d9ffdb7f5e..e568ba9e15 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -53,6 +53,38 @@ jobs: fail_ci_if_error: false file: ./coverage.xml + cron-pt-image: + if: github.repository == 'Project-MONAI/MONAI' + container: + image: nvcr.io/nvidia/pytorch:20.12-py3 # testing with the latest pytorch base image + options: "--gpus all" + runs-on: [self-hosted, linux, x64, common] + steps: + - uses: actions/checkout@v2 + - name: Install the dependencies + run: | + which python + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + python -m pip list + - name: Run tests report coverage + run: | + export LAUNCH_DELAY=$[ $RANDOM % 16 * 60 ] + echo "Sleep $LAUNCH_DELAY" + sleep $LAUNCH_DELAY + nvidia-smi + export CUDA_VISIBLE_DEVICES=$(python -m tests.utils) + echo $CUDA_VISIBLE_DEVICES + python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))" + python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))' + BUILD_MONAI=1 ./runtests.sh --coverage + coverage xml + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false + file: ./coverage.xml + cron-docker: if: github.repository == 'Project-MONAI/MONAI' container: @@ -61,7 +93,8 @@ jobs: runs-on: [self-hosted, linux, x64, common] steps: - name: Run tests report coverage - # The docker image process has done the compilation. BUILD_MONAI=1 may not be necessary. + # The docker image process has done the compilation. + # BUILD_MONAI=1 is necessary for triggering the USE_COMPILED flag. run: | cd /opt/monai nvidia-smi diff --git a/Dockerfile b/Dockerfile index a600f9de84..d0384c7bee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.10-py3 +ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.12-py3 FROM ${PYTORCH_IMAGE} diff --git a/tests/test_ensemble_evaluator.py b/tests/test_ensemble_evaluator.py index fdb9695476..9cc977d876 100644 --- a/tests/test_ensemble_evaluator.py +++ b/tests/test_ensemble_evaluator.py @@ -55,7 +55,7 @@ def forward(self, x): def run_post_transform(engine): for i in range(5): expected_value = engine.state.iteration + i - torch.testing.assert_allclose(engine.state.output[f"pred{i}"], expected_value) + torch.testing.assert_allclose(engine.state.output[f"pred{i}"], torch.tensor([[expected_value]])) val_engine.run() diff --git a/tests/test_handler_checkpoint_loader.py b/tests/test_handler_checkpoint_loader.py index d299b65e9b..8b0f752ff4 100644 --- a/tests/test_handler_checkpoint_loader.py +++ b/tests/test_handler_checkpoint_loader.py @@ -40,7 +40,7 @@ def test_one_save_one_load(self): engine = Engine(lambda e, b: None) CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine) engine.run([0] * 8, max_epochs=1) - torch.testing.assert_allclose(net2.state_dict()["weight"], 0.1) + torch.testing.assert_allclose(net2.state_dict()["weight"], torch.tensor([0.1])) def test_two_save_one_load(self): logging.basicConfig(stream=sys.stdout, level=logging.INFO) @@ -62,7 +62,7 @@ def test_two_save_one_load(self): engine = Engine(lambda e, b: None) CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine) engine.run([0] * 8, max_epochs=1) - torch.testing.assert_allclose(net2.state_dict()["weight"], 0.1) + torch.testing.assert_allclose(net2.state_dict()["weight"], torch.tensor([0.1])) def test_save_single_device_load_multi_devices(self): logging.basicConfig(stream=sys.stdout, level=logging.INFO) @@ -83,7 +83,7 @@ def test_save_single_device_load_multi_devices(self): engine = Engine(lambda e, b: None) CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine) engine.run([0] * 8, max_epochs=1) - torch.testing.assert_allclose(net2.state_dict()["module.weight"].cpu(), 0.1) + torch.testing.assert_allclose(net2.state_dict()["module.weight"].cpu(), torch.tensor([0.1])) if __name__ == "__main__":