--cpu

πŸ¦‰ 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

Force the neural model to train on the CPU even if a CUDA or Apple MPS GPU is detected.

Typeboolean flag (store_true)
Defaultoff (GPU used when available)
Maps toTrainerConfig.force_cpu
Read intrain.py β†’ src/training/trainer.py (Trainer.__init__) β†’ src/training/device.py (detect_device())

What it does

Trainer.__init__ calls detect_device(force_cpu=cfg.force_cpu) (src/training/device.py). With --cpu, detection short-circuits immediately and returns ("cpu", "CPU (forced via --cpu)") β€” torch is not even imported for detection. Without it, the order is: CUDA (torch.cuda.is_available(), reporting GPU name and VRAM), then Apple MPS, then CPU.

The chosen device is only used by _train_nn(), which passes it to TorchMLPClassifier(device=...); in fit() the network and each mini-batch are moved to that device. Everything else β€” CSV parsing, sample generation (multi-process CPU), sklearn models β€” is CPU-bound regardless of this flag.

Note the flag only affects training. At predict/load time, TorchMLPClassifier._ensure_net() re-detects the machine’s device on its own (cuda if available, else cpu).

Choosing a value

  • Use it to keep the GPU free for other work, to rule out GPU driver/CUDA issues when debugging, or for reproducibility comparisons.
  • CPU training is slower per epoch; the docstring example compensates with more epochs (--cpu --epochs 50), though epochs are independent of the device.
  • If you don’t have a GPU there is no need for this flag β€” detection falls back to CPU automatically.

Examples

python train.py --cpu
python train.py --cpu --epochs 50

Interactions

  • --check-gpu β€” shows what would be detected (without --cpu applied; --check-gpu calls detect_device() with no force flag).
  • --no-nn β€” if the NN is skipped, the device choice only affects the startup log line.
  • --batch-size β€” GPU memory pressure disappears on CPU, but large batches still cost RAM.

See also

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