[Core] Gpu type detection (#9695)

* .

* .

* .

* .

* .

* .

* .

* .

* Test cases

* detection only

* .

* Done?

* .

* .

* Done

* added test case

* .

* .

* .

* .

* .

* .

* Update python/ray/ray_constants.py

Co-authored-by: Eric Liang <ekhliang@gmail.com>

* .

* .

Co-authored-by: Eric Liang <ekhliang@gmail.com>
This commit is contained in:
Alex Wu
2020-08-01 11:43:56 -07:00
committed by GitHub
co-authored by Eric Liang
parent 64d6446cf3
commit 5b96a88cd7
3 changed files with 113 additions and 0 deletions
+39
View File
@@ -15,6 +15,7 @@ import ray
import ray.ray_constants as ray_constants
import ray.cluster_utils
import ray.test_utils
from ray import resource_spec
import setproctitle
from ray.test_utils import (check_call_ray, RayTestTimeoutException,
@@ -683,6 +684,44 @@ def test_ray_address_environment_variable(ray_start_cluster):
ray.shutdown()
def test_gpu_info_parsing():
info_string = """Model: Tesla V100-SXM2-16GB
IRQ: 107
GPU UUID: GPU-8eaaebb8-bb64-8489-fda2-62256e821983
Video BIOS: 88.00.4f.00.09
Bus Type: PCIe
DMA Size: 47 bits
DMA Mask: 0x7fffffffffff
Bus Location: 0000:00:1e.0
Device Minor: 0
Blacklisted: No
"""
constraints_dict = resource_spec._constraints_from_gpu_info(info_string)
expected_dict = {
"{}V100".format(ray_constants.RESOURCE_CONSTRAINT_PREFIX): 1
}
assert constraints_dict == expected_dict
info_string = """Model: Tesla T4
IRQ: 10
GPU UUID: GPU-415fe7a8-f784-6e3d-a958-92ecffacafe2
Video BIOS: 90.04.84.00.06
Bus Type: PCIe
DMA Size: 47 bits
DMA Mask: 0x7fffffffffff
Bus Location: 0000:00:1b.0
Device Minor: 0
Blacklisted: No
"""
constraints_dict = resource_spec._constraints_from_gpu_info(info_string)
expected_dict = {
"{}T4".format(ray_constants.RESOURCE_CONSTRAINT_PREFIX): 1
}
assert constraints_dict == expected_dict
assert resource_spec._constraints_from_gpu_info(None) == {}
if __name__ == "__main__":
import pytest
sys.exit(pytest.main(["-v", __file__]))