Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions monai/config/deviceconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,31 @@ def get_system_info() -> OrderedDict:
"""
output: OrderedDict = OrderedDict()

_dict_append(output, "System", lambda: platform.system())
_dict_append(output, "System", platform.system)
if output["System"] == "Windows":
_dict_append(output, "Win32 version", lambda: platform.win32_ver())
_dict_append(output, "Win32 version", platform.win32_ver)
if hasattr(platform, "win32_edition"):
_dict_append(output, "Win32 edition", lambda: platform.win32_edition()) # type:ignore[attr-defined]
_dict_append(output, "Win32 edition", platform.win32_edition) # type:ignore[attr-defined]
elif output["System"] == "Darwin":
_dict_append(output, "Mac version", lambda: platform.mac_ver()[0])
else:
linux_ver = re.search(r'PRETTY_NAME="(.*)"', open("/etc/os-release", "r").read())
if linux_ver:
_dict_append(output, "Linux version", lambda: linux_ver.group(1))

_dict_append(output, "Platform", lambda: platform.platform())
_dict_append(output, "Processor", lambda: platform.processor())
_dict_append(output, "Machine", lambda: platform.machine())
_dict_append(output, "Python version", lambda: platform.python_version())
_dict_append(output, "Platform", platform.platform)
_dict_append(output, "Processor", platform.processor)
_dict_append(output, "Machine", platform.machine)
_dict_append(output, "Python version", platform.python_version)

if not has_psutil:
_dict_append(output, "`psutil` missing", lambda: "run `pip install monai[psutil]`")
else:
p = psutil.Process()
with p.oneshot():
_dict_append(output, "Process name", lambda: p.name())
_dict_append(output, "Command", lambda: p.cmdline())
_dict_append(output, "Open files", lambda: p.open_files())
_dict_append(output, "Process name", p.name)
_dict_append(output, "Command", p.cmdline)
_dict_append(output, "Open files", p.open_files)
_dict_append(output, "Num physical CPUs", lambda: psutil.cpu_count(logical=False))
_dict_append(output, "Num logical CPUs", lambda: psutil.cpu_count(logical=True))
_dict_append(output, "Num usable CPUs", lambda: len(psutil.Process().cpu_affinity()))
Expand Down Expand Up @@ -204,8 +204,9 @@ def get_gpu_info() -> OrderedDict:
_dict_append(output, "cuDNN version", lambda: cudnn_ver)

if num_gpus > 0:
_dict_append(output, "Current device", lambda: torch.cuda.current_device())
_dict_append(output, "Library compiled for CUDA architectures", lambda: torch.cuda.get_arch_list())
_dict_append(output, "Current device", torch.cuda.current_device)
if hasattr(torch.cuda, "get_arch_list"): # get_arch_list is new in torch 1.7.1
_dict_append(output, "Library compiled for CUDA architectures", torch.cuda.get_arch_list)
for gpu in range(num_gpus):
_dict_append(output, "Info for GPU", gpu)
gpu_info = torch.cuda.get_device_properties(gpu)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]

TEST_CASE_3 = [
{"sigmoid": False, "softmax": False, "other": lambda x: torch.tanh(x)},
{"sigmoid": False, "softmax": False, "other": torch.tanh},
torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]),
torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]]),
(1, 1, 2, 2),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_activationsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]

TEST_CASE_2 = [
{"keys": ["pred", "label"], "sigmoid": False, "softmax": False, "other": [lambda x: torch.tanh(x), None]},
{"keys": ["pred", "label"], "sigmoid": False, "softmax": False, "other": [torch.tanh, None]},
{"pred": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]), "label": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]])},
{
"pred": torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]]),
Expand All @@ -37,7 +37,7 @@
]

TEST_CASE_3 = [
{"keys": "pred", "sigmoid": False, "softmax": False, "other": lambda x: torch.tanh(x)},
{"keys": "pred", "sigmoid": False, "softmax": False, "other": torch.tanh},
{"pred": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]])},
{"pred": torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]])},
(1, 1, 2, 2),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"data_shape": True,
"value_range": True,
"data_value": True,
"additional_info": lambda x: np.mean(x),
"additional_info": np.mean,
"logger_handler": None,
},
np.array([[0, 1], [1, 2]]),
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_file(self, input_data, expected_print):
"data_shape": True,
"value_range": True,
"data_value": True,
"additional_info": lambda x: np.mean(x),
"additional_info": np.mean,
"logger_handler": handler,
}
transform = DataStats(**input_param)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_data_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"data_shape": True,
"value_range": True,
"data_value": True,
"additional_info": lambda x: np.mean(x),
"additional_info": np.mean,
},
{"img": np.array([[0, 1], [1, 2]])},
"test data statistics:\nShape: (2, 2)\nValue range: (0, 2)\nValue: [[0 1]\n [1 2]]\nAdditional info: 1.0",
Expand Down Expand Up @@ -108,7 +108,7 @@
"data_shape": True,
"value_range": (True, False),
"data_value": (False, True),
"additional_info": (lambda x: np.mean(x), None),
"additional_info": (np.mean, None),
},
{"img": np.array([[0, 1], [1, 2]]), "affine": np.eye(2, 2)},
"affine statistics:\nShape: (2, 2)\nValue: [[1. 0.]\n [0. 1.]]",
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_file(self, input_data, expected_print):
"data_shape": True,
"value_range": True,
"data_value": True,
"additional_info": lambda x: np.mean(x),
"additional_info": np.mean,
"logger_handler": handler,
}
transform = DataStatsd(**input_param)
Expand Down