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]
| Parameter | Type | Default | Meaning |
|---|---|---|---|
force_cpu | bool | False | Skip all detection and return CPU (set by the --cpu flag) |
Returns (device, description) where device is one of "cuda", "mps", "cpu". Decision order:
force_cpuβ("cpu", "CPU (forced via --cpu)").import torchfails β("cpu", "CPU (PyTorch not installed β pip install torch for GPU training)").torch.cuda.is_available()β("cuda", "GPU: <name> (<vram> GB VRAM)")using device 0βs name and total memory.- Apple MPS available β
("mps", "GPU: Apple Metal (MPS)"). - 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
- GPU guide
- βcheck-gpu, βcpu
- torch-model.md β the consumer of the device string
π¬ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord β or prototype strategies no-code with ChipaEditor.