(platform="cuda")
| 19 | |
| 20 | |
| 21 | def check_ai_device(platform="cuda"): |
| 22 | platform_device = PLATFORM_DEVICE_REGISTER.get(platform, None) |
| 23 | if platform_device is None: |
| 24 | available_platforms = list(PLATFORM_DEVICE_REGISTER.keys()) |
| 25 | raise RuntimeError(f"Unsupported PLATFORM: {platform}. Available PLATFORM: {available_platforms}") |
| 26 | is_available = platform_device.is_available() |
| 27 | if not is_available: |
| 28 | skip_platform_check = os.getenv("SKIP_PLATFORM_CHECK", "False") in ["1", "True"] |
| 29 | error_msg = f"AI device for platform '{platform}' is not available. Please check your runtime environment." |
| 30 | if skip_platform_check: |
| 31 | logger.warning(error_msg) |
| 32 | return True |
| 33 | raise RuntimeError(error_msg) |
| 34 | logger.info(f"AI device for platform '{platform}' is available.") |
| 35 | return True |
no test coverage detected