获取base port
()
| 30 | |
| 31 | |
| 32 | def get_base_port(): |
| 33 | """获取base port""" |
| 34 | nv_visible_devices = os.environ.get("CUDA_VISIBLE_DEVICES", "") |
| 35 | if not nv_visible_devices or nv_visible_devices.lower() == "all": |
| 36 | return 8000 |
| 37 | # 提取第一个数字 |
| 38 | match = re.search(r"\d+", nv_visible_devices) |
| 39 | if match: |
| 40 | return int(match.group(0)) * 100 + 8000 |
| 41 | return 8000 |
| 42 | |
| 43 | |
| 44 | def is_port_in_use(port): |