cuda_malloc: add missing GPUs to blacklist and fix bare except clauses #12333
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #940 - Adds GPU models reported by users in the issue that are missing from the
cudaMallocAsyncblacklist, and replaces bareexcept:withexcept Exception:for better Python practices.Changes
1. Added missing GPUs to the blacklist
Several users reported
CUDA error: operation not supportedon GPUs not yet in the blacklist. These have been added:--disable-cuda-mallocfixed itThe blacklist uses substring matching (
if b in x), so these entries correctly match the full GPU name strings returned by bothnvidia-smi -L(Linux) andEnumDisplayDevicesA(Windows).2. Replaced bare
except:withexcept Exception:Three locations in the file used bare
except:which catches all exceptions includingKeyboardInterruptandSystemExit. This is a Python anti-pattern (PEP 8, B001/E722). Changed toexcept Exception:which still catches all operational errors (OSError,FileNotFoundError,RuntimeError,CalledProcessError, etc.) but allows clean process termination.Locations changed:
cuda_malloc_supported()- catches failures fromget_gpu_names()(nvidia-smi/ctypes)Testing
except Exception:catchesRuntimeError,OSError,FileNotFoundError,CalledProcessError; correctly does NOT catchKeyboardInterruptorSystemExitpy_compilepasses