@@ -33,8 +33,19 @@ def _checkpoint_available():
3333 try :
3434 checkpoint ._get_driver ()
3535 return True
36- except RuntimeError :
37- return False
36+ except RuntimeError as exc :
37+ if _checkpoint_unavailable_can_skip (str (exc )):
38+ return False
39+ raise
40+
41+
42+ def _checkpoint_unavailable_can_skip (message ):
43+ return message .startswith (
44+ (
45+ "CUDA checkpointing is not supported by the installed NVIDIA driver." ,
46+ "CUDA checkpointing requires cuda.bindings with CUDA checkpoint API support. Found cuda.bindings " ,
47+ )
48+ )
3849
3950
4051needs_checkpoint = pytest .mark .skipif (
@@ -384,6 +395,37 @@ def test_public_symbols(self):
384395 assert checkpoint .__all__ == ["Process" ]
385396 assert not hasattr (checkpoint , "ProcessStateType" )
386397
398+ def test_checkpoint_available_skips_unsupported_driver (self , monkeypatch ):
399+ def raise_unsupported_driver ():
400+ raise RuntimeError ("CUDA checkpointing is not supported by the installed NVIDIA driver." )
401+
402+ monkeypatch .setattr (checkpoint , "_get_driver" , raise_unsupported_driver )
403+
404+ assert not _checkpoint_available ()
405+
406+ def test_checkpoint_available_skips_old_bindings (self , monkeypatch ):
407+ def raise_old_bindings ():
408+ raise RuntimeError (
409+ "CUDA checkpointing requires cuda.bindings with CUDA checkpoint API support. "
410+ "Found cuda.bindings 12.7.0."
411+ )
412+
413+ monkeypatch .setattr (checkpoint , "_get_driver" , raise_old_bindings )
414+
415+ assert not _checkpoint_available ()
416+
417+ def test_checkpoint_available_fails_missing_required_bindings (self , monkeypatch ):
418+ def raise_missing_binding ():
419+ raise RuntimeError (
420+ "CUDA checkpointing requires cuda.bindings with CUDA checkpoint API support. "
421+ "Missing: CUcheckpointRestoreArgs"
422+ )
423+
424+ monkeypatch .setattr (checkpoint , "_get_driver" , raise_missing_binding )
425+
426+ with pytest .raises (RuntimeError , match = "Missing: CUcheckpointRestoreArgs" ):
427+ _checkpoint_available ()
428+
387429 def test_pid_is_read_only (self ):
388430 proc = checkpoint .Process (1 )
389431 assert proc .pid == 1
0 commit comments