Skip to content

Commit 75b78cd

Browse files
authored
1545 upgrade base image to pytorch 20.12 (#1613)
* test new image Signed-off-by: Wenqi Li <[email protected]> * temp no cron Signed-off-by: Wenqi Li <[email protected]> * fixes unit tests Signed-off-by: Wenqi Li <[email protected]> * adds base docker test Signed-off-by: Wenqi Li <[email protected]> * undo temp tests Signed-off-by: Wenqi Li <[email protected]>
1 parent a664506 commit 75b78cd

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

.github/workflows/cron.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,38 @@ jobs:
5353
fail_ci_if_error: false
5454
file: ./coverage.xml
5555

56+
cron-pt-image:
57+
if: github.repository == 'Project-MONAI/MONAI'
58+
container:
59+
image: nvcr.io/nvidia/pytorch:20.12-py3 # testing with the latest pytorch base image
60+
options: "--gpus all"
61+
runs-on: [self-hosted, linux, x64, common]
62+
steps:
63+
- uses: actions/checkout@v2
64+
- name: Install the dependencies
65+
run: |
66+
which python
67+
python -m pip install --upgrade pip wheel
68+
python -m pip install -r requirements-dev.txt
69+
python -m pip list
70+
- name: Run tests report coverage
71+
run: |
72+
export LAUNCH_DELAY=$[ $RANDOM % 16 * 60 ]
73+
echo "Sleep $LAUNCH_DELAY"
74+
sleep $LAUNCH_DELAY
75+
nvidia-smi
76+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
77+
echo $CUDA_VISIBLE_DEVICES
78+
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
79+
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
80+
BUILD_MONAI=1 ./runtests.sh --coverage
81+
coverage xml
82+
- name: Upload coverage
83+
uses: codecov/codecov-action@v1
84+
with:
85+
fail_ci_if_error: false
86+
file: ./coverage.xml
87+
5688
cron-docker:
5789
if: github.repository == 'Project-MONAI/MONAI'
5890
container:
@@ -61,7 +93,8 @@ jobs:
6193
runs-on: [self-hosted, linux, x64, common]
6294
steps:
6395
- name: Run tests report coverage
64-
# The docker image process has done the compilation. BUILD_MONAI=1 may not be necessary.
96+
# The docker image process has done the compilation.
97+
# BUILD_MONAI=1 is necessary for triggering the USE_COMPILED flag.
6598
run: |
6699
cd /opt/monai
67100
nvidia-smi

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
1111

12-
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.10-py3
12+
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.12-py3
1313

1414
FROM ${PYTORCH_IMAGE}
1515

tests/test_ensemble_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def forward(self, x):
5555
def run_post_transform(engine):
5656
for i in range(5):
5757
expected_value = engine.state.iteration + i
58-
torch.testing.assert_allclose(engine.state.output[f"pred{i}"], expected_value)
58+
torch.testing.assert_allclose(engine.state.output[f"pred{i}"], torch.tensor([[expected_value]]))
5959

6060
val_engine.run()
6161

tests/test_handler_checkpoint_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_one_save_one_load(self):
4040
engine = Engine(lambda e, b: None)
4141
CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine)
4242
engine.run([0] * 8, max_epochs=1)
43-
torch.testing.assert_allclose(net2.state_dict()["weight"], 0.1)
43+
torch.testing.assert_allclose(net2.state_dict()["weight"], torch.tensor([0.1]))
4444

4545
def test_two_save_one_load(self):
4646
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
@@ -62,7 +62,7 @@ def test_two_save_one_load(self):
6262
engine = Engine(lambda e, b: None)
6363
CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine)
6464
engine.run([0] * 8, max_epochs=1)
65-
torch.testing.assert_allclose(net2.state_dict()["weight"], 0.1)
65+
torch.testing.assert_allclose(net2.state_dict()["weight"], torch.tensor([0.1]))
6666

6767
def test_save_single_device_load_multi_devices(self):
6868
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
@@ -83,7 +83,7 @@ def test_save_single_device_load_multi_devices(self):
8383
engine = Engine(lambda e, b: None)
8484
CheckpointLoader(load_path=path, load_dict={"net": net2}).attach(engine)
8585
engine.run([0] * 8, max_epochs=1)
86-
torch.testing.assert_allclose(net2.state_dict()["module.weight"].cpu(), 0.1)
86+
torch.testing.assert_allclose(net2.state_dict()["module.weight"].cpu(), torch.tensor([0.1]))
8787

8888

8989
if __name__ == "__main__":

0 commit comments

Comments
 (0)