src.training.device

πŸ¦‰ AthenaAI is an AI-powered ensemble machine-learning trading bot for PocketOption, built on BinaryOptionsToolsV2 β†’ Get it on GitLab
πŸ’¬ Need help? Join the Chipa Discord Β· ⚑ Go no-code with ChipaEditor

Source: src/training/device.py. Decides which device the neural model trains on. PyTorch is optional β€” everything degrades to CPU/sklearn-only when it is missing.

detect_device(force_cpu: bool = False) -> tuple[str, str]

ParameterTypeDefaultMeaning
force_cpuboolFalseSkip all detection and return CPU (set by the --cpu flag)

Returns (device, description) where device is one of "cuda", "mps", "cpu". Decision order:

  1. force_cpu β†’ ("cpu", "CPU (forced via --cpu)").
  2. import torch fails β†’ ("cpu", "CPU (PyTorch not installed β€” pip install torch for GPU training)").
  3. torch.cuda.is_available() β†’ ("cuda", "GPU: <name> (<vram> GB VRAM)") using device 0’s name and total memory.
  4. Apple MPS available β†’ ("mps", "GPU: Apple Metal (MPS)").
  5. Otherwise β†’ ("cpu", "CPU (PyTorch installed but no GPU available)").

No side effects, no logging, never raises. train.py --check-gpu prints exactly this pair and exits.

log_device(device: str, desc: str) -> None

Logs one line: ⚑ Training device: <desc> for GPU devices, πŸ–₯ Training device: <desc> for CPU. Called by Trainer.run().

Usage example

from src.training.device import detect_device, log_device

device, desc = detect_device()
log_device(device, desc)
# 12:00:01 β”‚ INFO    β”‚ ⚑ Training device: GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)

Or from the shell:

python train.py --check-gpu
# Device: cuda  (GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM))

See also

πŸ’¬ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord β€” or prototype strategies no-code with ChipaEditor.