()
| 190 | |
| 191 | |
| 192 | def main(): |
| 193 | parser = argparse.ArgumentParser( |
| 194 | description="CUDA process checkpoint sample using cuda.core", |
| 195 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 196 | ) |
| 197 | parser.add_argument( |
| 198 | "--device", type=int, default=0, help="CUDA device ID (default: 0)" |
| 199 | ) |
| 200 | parser.add_argument( |
| 201 | "--buffer-mib", |
| 202 | type=int, |
| 203 | default=16, |
| 204 | help="GPU buffer size in MiB (default: 16)", |
| 205 | ) |
| 206 | parser.add_argument( |
| 207 | "--lock-timeout-ms", |
| 208 | type=int, |
| 209 | default=5000, |
| 210 | help="Timeout passed to Process.lock in ms (default: 5000)", |
| 211 | ) |
| 212 | args = parser.parse_args() |
| 213 | |
| 214 | if sys.platform != "linux": |
| 215 | print("CUDA process checkpointing is Linux-only.") |
| 216 | return 2 |
| 217 | |
| 218 | if args.buffer_mib <= 0: |
| 219 | print("Error: --buffer-mib must be positive") |
| 220 | return 1 |
| 221 | |
| 222 | print("[Process Checkpoint Sample using CUDA Core API]") |
| 223 | print(f"PID: {os.getpid()}") |
| 224 | |
| 225 | device = Device(args.device) |
| 226 | device.set_current() |
| 227 | print(f"Device: {device.name}") |
| 228 | print(f"Compute Capability: sm_{device.arch}") |
| 229 | print(f"Buffer size: {args.buffer_mib} MiB") |
| 230 | print(f"Lock timeout: {args.lock_timeout_ms} ms") |
| 231 | |
| 232 | # CUDA process checkpointing relies on kernel-mode driver features |
| 233 | # that aren't shipped on integrated-GPU platforms (e.g. Tegra / |
| 234 | # Jetson / Thor). There Process.lock() still succeeds and only |
| 235 | # Process.checkpoint() reports the missing support, which leaves the |
| 236 | # process locked and hanging on exit, so the check below cannot cover |
| 237 | # it. Remove this guard once integrated platforms gain checkpoint |
| 238 | # support. |
| 239 | if device.properties.integrated: |
| 240 | print( |
| 241 | f"CUDA process checkpointing is not supported on integrated " |
| 242 | f"GPUs (sm_{device.arch}), waiving this sample." |
| 243 | ) |
| 244 | return 2 |
| 245 | |
| 246 | print() |
| 247 | print("Compiling kernel ...") |
| 248 | fill_kernel = compile_fill_kernel(device) |
| 249 |
no test coverage detected