File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
tests/ignite/contrib/metrics Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+
13import torch
24
35from ignite .contrib .metrics import GpuMemory
79
810@pytest .fixture
911def no_site_packages ():
10- try :
11- import pynvml
12- except ImportError :
13- yield "no_site_packages"
14- return
12+ import pynvml
1513 import sys
1614 assert 'pynvml' in sys .modules
1715 pynvml_module = sys .modules ['pynvml' ]
@@ -23,20 +21,22 @@ def no_site_packages():
2321 sys .modules ['pynvml' ] = pynvml_module
2422
2523
24+ @pytest .mark .skipif (sys .version [0 ] == "2" , reason = "No pynvml for python 2.7" )
2625def test_no_pynvml_package (no_site_packages ):
2726
2827 with pytest .raises (RuntimeError , match = "This contrib module requires pynvml to be installed." ):
2928 GpuMemory ()
3029
3130
32- @pytest .mark .skipif (torch .cuda .is_available (), reason = "Skip if has GPU " )
31+ @pytest .mark .skipif (sys . version [ 0 ] == "2" or torch .cuda .is_available (), reason = "No pynvml for python 2.7 " )
3332def test_no_gpu ():
3433
3534 with pytest .raises (RuntimeError , match = "This contrib module requires available GPU" ):
3635 GpuMemory ()
3736
3837
39- @pytest .mark .skipif (torch .cuda .is_available (), reason = "Skip if has GPU" )
38+ @pytest .mark .skipif (sys .version [0 ] == "2" or not (torch .cuda .is_available ()),
39+ reason = "No pynvml for python 2.7 and no GPU" )
4040def test_gpu_mem_consumption ():
4141
4242 gpu_mem = GpuMemory ()
You can’t perform that action at this time.
0 commit comments