Environment:Sktime Pytorch forecasting Core Python Dependencies
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Deep_Learning, Time_Series |
| Last Updated | 2026-02-08 08:00 GMT |
Overview
Python 3.10+ environment with PyTorch >= 2.0, Lightning >= 2.0, pandas, scikit-learn, scipy, and numpy as mandatory runtime dependencies.
Description
This environment defines the core dependency stack required for all pytorch-forecasting functionality. It is built on PyTorch for tensor operations, Lightning for training orchestration, pandas for data handling, scikit-learn for preprocessing utilities, and scipy for statistical operations. The package excludes PyTorch 2.0.1 due to known bugs and pins Lightning below 2.7.0 for compatibility. A runtime adaptation detects Lightning >= 2.6 and adjusts checkpoint loading behavior (weights_only parameter) accordingly.
Usage
This environment is required for all pytorch-forecasting workflows. Every Implementation page depends on these core packages being installed. Without this environment, no models, datasets, or metrics can be used.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, or Windows | macOS requires `brew install libomp` for PyTorch OpenMP support |
| Hardware | CPU minimum; NVIDIA GPU optional | CUDA GPU accelerates training but is not required; MPS (Apple Silicon) partially supported |
| Python | >= 3.10, < 3.15 | Tested on 3.10, 3.11, 3.12, 3.13, 3.14 |
| Disk | ~2GB | For core dependencies installation |
Dependencies
System Packages
- `libomp` (macOS only, via Homebrew) — required by PyTorch for OpenMP parallelism
Python Packages
- `torch` >= 2.0.0, != 2.0.1, < 3.0.0
- `lightning` >= 2.0.0, < 2.7.0
- `numpy` <= 3.0.0
- `scipy` >= 1.8, < 2.0
- `pandas` >= 1.3.0, < 3.0.0
- `scikit-learn` >= 1.2, < 2.0
- `scikit-base` < 0.14.0
Credentials
No credentials are required for the core dependency stack.
Quick Install
# Install pytorch-forecasting with all core dependencies
pip install pytorch-forecasting
# On macOS, also install libomp for PyTorch
brew install libomp
Code Evidence
Core dependency declarations from `pyproject.toml:9,29-37`:
requires-python = ">=3.10,<3.15"
dependencies = [
"numpy<=3.0.0",
"torch >=2.0.0,!=2.0.1,<3.0.0",
"lightning >=2.0.0,<2.7.0",
"scipy >=1.8,<2.0",
"pandas >=1.3.0,<3.0.0",
"scikit-learn >=1.2,<2.0",
"scikit-base <0.14.0",
]
Lightning >= 2.6 adaptation from `models/base/_base_model.py:820-826`:
from skbase.utils.dependencies import _check_soft_dependencies
if not _check_soft_dependencies("lightning<2.6", severity="none"):
if "weights_only" not in kwargs:
kwargs["weights_only"] = False
else:
kwargs.pop("weights_only", None)
MPS device handling with graceful fallback from `utils/_utils.py:463-471`:
if isinstance(device, str):
if device == "mps":
if hasattr(torch.backends, device):
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
device = torch.device("mps")
else:
device = torch.device("cpu")
else:
device = torch.device(device)
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ModuleNotFoundError: No module named 'lightning'` | Lightning not installed | `pip install lightning>=2.0.0` |
| `torch 2.0.1 is excluded` | Known-buggy PyTorch release | Install any other torch version: `pip install torch>=2.0.0,!=2.0.1` |
| `MPS accelerator has a bug` | MultivariateNormalDistributionLoss used on Apple MPS | Use CPU or CUDA instead of MPS for multivariate distribution losses |
| `weights_only` TypeError on checkpoint load | Lightning < 2.6 does not accept this parameter | The library handles this automatically; ensure pytorch-forecasting is up to date |
Compatibility Notes
- macOS: Requires `brew install libomp` for PyTorch OpenMP threading. MPS (Apple Silicon) is partially supported but has known bugs with multivariate normal distributions (`pytorch/pytorch#98074`). MPS is globally disabled in the test suite.
- Windows: Core functionality works but DDP (distributed data parallel) tests are skipped due to known issues (`#1623`). Hyperparameter tuning tests are also skipped on Windows.
- CUDA: Fully supported but not required. Tests run on CPU by default. If CUDA is available, it is auto-detected via `accelerator="auto"` in Lightning Trainer.
Related Pages
- Implementation:Sktime_Pytorch_forecasting_Get_Stallion_Data
- Implementation:Sktime_Pytorch_forecasting_Generate_Ar_Data
- Implementation:Sktime_Pytorch_forecasting_TimeSeriesDataSet_Init
- Implementation:Sktime_Pytorch_forecasting_TimeSeriesDataSet_From_Dataset
- Implementation:Sktime_Pytorch_forecasting_TimeSeriesDataSet_To_Dataloader
- Implementation:Sktime_Pytorch_forecasting_Lightning_Trainer
- Implementation:Sktime_Pytorch_forecasting_TemporalFusionTransformer_From_Dataset
- Implementation:Sktime_Pytorch_forecasting_DeepAR_From_Dataset
- Implementation:Sktime_Pytorch_forecasting_NBeats_From_Dataset
- Implementation:Sktime_Pytorch_forecasting_Tuner_Lr_Find
- Implementation:Sktime_Pytorch_forecasting_Trainer_Fit
- Implementation:Sktime_Pytorch_forecasting_DeepAR_Predict
- Implementation:Sktime_Pytorch_forecasting_QuantileLoss
- Implementation:Sktime_Pytorch_forecasting_NormalDistributionLoss
- Implementation:Sktime_Pytorch_forecasting_GroupNormalizer
- Implementation:Sktime_Pytorch_forecasting_NaNLabelEncoder
- Implementation:Sktime_Pytorch_forecasting_Optimize_Hyperparameters