fix: auto-detect training device instead of defaulting to CUDA

The PassGPT training device menu now uses _detect_device() to default
to the best available device (CUDA > MPS > CPU) rather than always
defaulting to CUDA, which fails on systems without NVIDIA GPUs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Justin Bollinger
2026-02-18 18:47:41 -05:00
co-authored by Claude Opus 4.6
parent 0a80ac6d22
commit 14f5b36382
2 changed files with 21 additions and 8 deletions
+8 -2
View File
@@ -261,11 +261,14 @@ class TestPassGPTAttackHandler:
ctx.select_file_with_autocomplete.return_value = "/tmp/wordlist.txt"
ctx.hcatPassGPTTrain.return_value = "/home/user/.hate_crack/passgpt/wordlist"
# "T" for train, "" for default base model, "" for default device (cuda), "" for default max candidates
# "T" for train, "" for default base model, "" for default device (auto-detected), "" for default max candidates
inputs = iter(["T", "", "", ""])
with (
patch("builtins.input", side_effect=inputs),
patch("hate_crack.attacks.os.path.isdir", return_value=False),
patch(
"hate_crack.passgpt_train._detect_device", return_value="cuda"
),
):
from hate_crack.attacks import passgpt_attack
@@ -283,11 +286,14 @@ class TestPassGPTAttackHandler:
ctx.select_file_with_autocomplete.return_value = "/tmp/wordlist.txt"
ctx.hcatPassGPTTrain.return_value = None
# "T" for train, "" for default base model, "" for default device (cuda)
# "T" for train, "" for default base model, "" for default device (auto-detected)
inputs = iter(["T", "", ""])
with (
patch("builtins.input", side_effect=inputs),
patch("hate_crack.attacks.os.path.isdir", return_value=False),
patch(
"hate_crack.passgpt_train._detect_device", return_value="cuda"
),
):
from hate_crack.attacks import passgpt_attack