Skip to content

Commit d844caf

Browse files
authored
5150 fixes integration error reading stdout visible devices (#5154)
Signed-off-by: Wenqi Li <wenqil@nvidia.com> Fixes #5150 ### Description `python -m tests.utils` may print additional contents from 3rd party packages, only the last line for the stdout should be used ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Wenqi Li <wenqil@nvidia.com>
1 parent d763ca2 commit d844caf

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

.github/workflows/cron.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
echo "Sleep $LAUNCH_DELAY"
4343
sleep $LAUNCH_DELAY
4444
nvidia-smi
45-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
45+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
4646
echo $CUDA_VISIBLE_DEVICES
4747
trap 'if pgrep python; then pkill python; fi;' ERR
4848
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
@@ -85,7 +85,7 @@ jobs:
8585
echo "Sleep $LAUNCH_DELAY"
8686
sleep $LAUNCH_DELAY
8787
nvidia-smi
88-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
88+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
8989
echo $CUDA_VISIBLE_DEVICES
9090
trap 'if pgrep python; then pkill python; fi;' ERR
9191
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
@@ -160,7 +160,7 @@ jobs:
160160
echo "Sleep $LAUNCH_DELAY"
161161
sleep $LAUNCH_DELAY
162162
nvidia-smi
163-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
163+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
164164
echo $CUDA_VISIBLE_DEVICES
165165
trap 'if pgrep python; then pkill python; fi;' ERR
166166
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
@@ -183,7 +183,7 @@ jobs:
183183
run: |
184184
cd /opt/monai
185185
nvidia-smi
186-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
186+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
187187
echo $CUDA_VISIBLE_DEVICES
188188
trap 'if pgrep python; then pkill python; fi;' ERR
189189
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
@@ -217,7 +217,7 @@ jobs:
217217
python -m pip install -r requirements-dev.txt
218218
BUILD_MONAI=1 python setup.py develop # install monai
219219
nvidia-smi
220-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
220+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
221221
echo $CUDA_VISIBLE_DEVICES
222222
echo "::set-output name=devices::$CUDA_VISIBLE_DEVICES"
223223
- name: Checkout tutorials and install their requirements

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
steps:
9292
- name: Import
9393
run: |
94-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
94+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
9595
echo $CUDA_VISIBLE_DEVICES
9696
python -c 'import monai; monai.config.print_debug_info()'
9797
cd /opt/monai

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: |
4242
python -m pip list
4343
nvidia-smi
44-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
44+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
4545
echo $CUDA_VISIBLE_DEVICES
4646
trap 'if pgrep python; then pkill python; fi;' ERR
4747
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &

.github/workflows/pythonapp-gpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
export LAUNCH_DELAY=$(python -c "import numpy; print(numpy.random.randint(30) * 10)")
130130
echo "Sleep $LAUNCH_DELAY"
131131
sleep $LAUNCH_DELAY
132-
export CUDA_VISIBLE_DEVICES=$(coverage run -m tests.utils)
132+
export CUDA_VISIBLE_DEVICES=$(coverage run -m tests.utils | tail -n 1)
133133
echo $CUDA_VISIBLE_DEVICES
134134
trap 'if pgrep python; then pkill python; fi;' ERR
135135
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &

.github/workflows/setupapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
echo "Sleep $LAUNCH_DELAY"
5454
sleep $LAUNCH_DELAY
5555
nvidia-smi
56-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
56+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
5757
echo $CUDA_VISIBLE_DEVICES
5858
trap 'if pgrep python; then pkill python; fi;' ERR
5959
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tifffile; platform_system == "Linux"
3838
pandas
3939
requests
4040
einops
41-
transformers!=4.22.0
41+
transformers
4242
mlflow
4343
matplotlib!=3.5.0
4444
tensorboardX

tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,4 +778,5 @@ def command_line_tests(cmd, copy_env=True):
778778

779779

780780
if __name__ == "__main__":
781-
print(query_memory())
781+
print("\n", query_memory()) # print to stdout
782+
sys.exit(0)

0 commit comments

Comments
 (0)