Installation
Optiland supports Python 3.10 and above and can be installed via pip with optional extras or can be built from source. Choose the installation method that best fits your needs.
Quick Start (Core + CPU‑only PyTorch)
To install Optiland with PyTorch support (CPU only) in one step:
pip install optiland[torch]
This command installs the Optiland core plus the latest PyTorch wheels (CPU‑only) from PyPI.
Standard Install (Core Only)
If you only need the Optiland core (no PyTorch):
pip install optiland
Standard Install with GUI
If you wish to use the Optiland GUI:
pip install optiland[gui]
Development Extras
To install Optiland’s development dependencies-pytest, codecov, and linting tools-use:
pip install optiland[dev]
GPU‑Enabled PyTorch (Manual Install)
If you require GPU acceleration, you must install a CUDA‑enabled PyTorch build manually. First install Optiland (core or with dev extras if desired), then follow PyTorch’s official install instructions. For example, for CUDA 11.8:
pip install optiland
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Note that this command installs PyTorch with CUDA 11.8. This command may not be correct for your system. Refer to https://pytorch.org/get-started/locally/ for the latest installation instructions for your platform.
Installing from Source
To clone and install the latest development version:
Clone the repository
git clone https://github.com/optiland/optiland.gitChange the directory
cd optilandInstall with optional extras
Core only:
pip install .With PyTorch support (CPU‑only):
pip install .[torch]With development dependencies:
pip install .[dev]
Verify Your Installation
After installation, verify that Optiland imports correctly:
import optiland
Optionally, generate and render a sample lens:
from optiland.samples.objectives import ReverseTelephoto
lens = ReverseTelephoto()
lens.draw3D()
Note
The first import may take a few seconds as modules and JIT-compiled code are cached.
If you see “Module ‘torch’ not found” after installing optiland[torch], ensure your environment’s PyPI index can reach the official PyTorch packages, or install PyTorch manually as shown above.
For any other issues, please consult our GitHub Issues page.