Skip to content
Closed
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
2 changes: 1 addition & 1 deletion haystack/utils/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def _split_device_string(string: str) -> tuple[str, int | None]:
The device type and device id, if any.
"""
if ":" in string:
device_type, device_id_str = string.split(":")
device_type, device_id_str = string.split(":", maxsplit=1)
try:
device_id = int(device_id_str)
except ValueError as e:
Expand Down
3 changes: 3 additions & 0 deletions test/utils/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def test_device_creation():
with pytest.raises(ValueError, match="Device id must be >= 0"):
Device.gpu(-1)

with pytest.raises(ValueError, match="Device id must be an integer, got 0:1"):
Device.from_str("cuda:0:1")


def test_device_map():
device_map = DeviceMap({"layer1": Device.cpu(), "layer2": Device.gpu(1), "layer3": Device.disk()})
Expand Down
Loading