| 1 | #!/usr/bin/env python3 |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 4 | """Check that vllm.platforms import does not initialize CUDA.""" |
| 5 | |
| 6 | import os |
| 7 | |
| 8 | for key in ["CUDA_VISIBLE_DEVICES", "HIP_VISIBLE_DEVICES", "ROCR_VISIBLE_DEVICES"]: |
| 9 | os.environ.pop(key, None) |
| 10 | |
| 11 | import torch # noqa: E402 |
| 12 | |
| 13 | assert not torch.cuda.is_initialized(), "CUDA initialized before import" |
| 14 | |
| 15 | from vllm.platforms import current_platform # noqa: E402 |
| 16 | |
| 17 | assert not torch.cuda.is_initialized(), ( |
| 18 | f"CUDA was initialized during vllm.platforms import on {current_platform}" |
| 19 | ) |
| 20 | print("OK") |