Spaces:
Sleeping
Sleeping
Download libs/inference/tests/test_device_utils.py from MSGEncrypted/lesson-agent-dev: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/spaces/MSGEncrypted/lesson-agent-dev/resolve/main/libs/inference/tests/test_device_utils.py
- Command line
-
hf download hf://spaces/MSGEncrypted/lesson-agent-dev/libs/inference/tests/test_device_utils.py
-
curl -L -o test_device_utils.py https://huggingface.co/spaces/MSGEncrypted/lesson-agent-dev/resolve/main/libs/inference/tests/test_device_utils.py
675 Bytes
| from inference.device_utils import is_cuda_oom, iter_inference_device_plans | |
| def test_is_cuda_oom_matches_pytorch_message() -> None: | |
| exc = RuntimeError( | |
| "CUDA out of memory. Tried to allocate 384.00 MiB. " | |
| "GPU 0 has a total capacity of 3.68 GiB of which 350.19 MiB is free." | |
| ) | |
| assert is_cuda_oom(exc) | |
| def test_is_cuda_oom_rejects_other_errors() -> None: | |
| assert not is_cuda_oom(RuntimeError("disk full")) | |
| def test_iter_inference_device_plans_includes_cpu(monkeypatch) -> None: | |
| monkeypatch.setenv("INFERENCE_DEVICE", "cpu") | |
| plans = list(iter_inference_device_plans()) | |
| assert len(plans) == 1 | |
| assert plans[0].device == "cpu" | |