File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 22
33import torch
44
5+ _POSSIBLE_TEST_DEVICES = {"cpu" , "cuda:0" }
6+ _POSSIBLE_TEST_DTYPES = {"float32" , "float64" }
7+
58try :
69 _device_str = os .environ ["PYTEST_TORCH_DEVICE" ]
710except KeyError :
811 _device_str = "cpu" # Default to cpu if environment variable not set
912
10- if _device_str != "cuda:0" and _device_str != "cpu" :
11- raise ValueError (f"Invalid value of environment variable PYTEST_TORCH_DEVICE: { _device_str } " )
13+ if _device_str not in _POSSIBLE_TEST_DEVICES :
14+ raise ValueError (
15+ f"Invalid value of environment variable PYTEST_TORCH_DEVICE: { _device_str } .\n "
16+ f"Possible values: { _POSSIBLE_TEST_DEVICES } ."
17+ )
1218
1319if _device_str == "cuda:0" and not torch .cuda .is_available ():
1420 raise ValueError ('Requested device "cuda:0" but cuda is not available.' )
1521
1622DEVICE = torch .device (_device_str )
1723
18-
19- _POSSIBLE_TEST_DTYPES = {"float32" , "float64" }
20-
2124try :
2225 _dtype_str = os .environ ["PYTEST_TORCH_DTYPE" ]
2326except KeyError :
You can’t perform that action at this time.
0 commit comments