.. _installation:
Installation
============
All commands below use ``pip``. For editable (development) installs from a local
clone, pass the ``-e`` flag (e.g. ``pip install -e .``).
.. tip::
We recommend `uv `_ as a fast, modern package
manager. To use it, substitute ``uv pip`` for ``pip`` in all commands below.
PyPI
----
Install the stable version of |slmsuite|_ from `PyPI `_ using:
.. code-block:: console
pip install slmsuite
GitHub
------
Install the latest version of |slmsuite|_ from `GitHub `_ using:
.. code-block:: console
pip install git+https://github.com/holodyne/slmsuite
One can also clone |slmsuite|_ directly and add its directory to the Python path.
*Remember to install the dependencies (next sections)*.
.. code-block:: console
git clone https://github.com/holodyne/slmsuite
Required Dependencies
---------------------
The following python packages are necessary to run |slmsuite|_. These are listed as PyPI
dependencies and thus are installed automatically if PyPI is used to install.
- `python `_ >= 3.10
- `numpy `_
- `scipy `_
- `opencv-python `_
- `matplotlib `_
- `h5py `_
- `tqdm `_
One can also install these dependencies directly by calling the following inside
the package directory.
.. code-block:: console
pip install -e .
Hardware Dependencies
---------------------
The following python packages are *optional* acceleration or hardware requirements, which
the user can install selectively.
- GPU ``pip install -e ".[gpu]"``
- `cupy `_, highly recommended for GPU-accelerated holography.
Once installed, holograms and SLMs (unless ``gpu=False``) run on :mod:`cupy`;
camera frames are returned in host memory unless a simulated camera is called
with ``get_image(get=False)``. Without :mod:`cupy`, :mod:`numpy` is used as a backup.
The ``gpu`` extra installs ``cupy-cuda13x`` (CUDA 13). For another CUDA version,
skip the extra and ``pip install cupy-cudaYYx``, finding ``YY`` with
``nvcc --version``.
- Gradients ``pip install -e ".[torch]"``
- `pytorch `_, required for gradient-based (``"CG"``) hologram
optimization with a :mod:`torch.optim` optimizer, either in GPU or CPU mode. Uses :mod:`cupy` - :mod:`torch`
`interoperability `_
to pass data between modules without copying overhead, even on the GPU.
- Cameras ``pip install -e ".[cameras]"``
- `instrumental-lib `_
- `pylablib `_
- `pymmcore `_
- `pypylon `_
- `mvsdk `_ (non-PyPI)
- `PySpin `_ (non-PyPI)
- `tisgrabber `_ (non-PyPI)
- `thorlabs_tsi_sdk `_ (non-PyPI)
- `VmbPy `_ (non-PyPI)
- Other cameras are loaded directly via .dll.
- SLMs ``pip install -e ".[slms]"``
- `pyglet `_
- `hidapi `_ and
`pyyaml `_, for Texas Instruments PLMs
- Other SLMs are loaded via their vendor's SDK or .dll.
- Image saving ``pip install -e ".[images]"``
- For most images and videos, `imageio `_
- Many video formats additionally require `pyav `_
- For .gif optimization, `pygifsicle `_
Jupyter
-------
We highly recommended using `Jupyter `_
notebooks for interactive computing. Consider also using
`IPython `_
`magic `_,
features like |autoreload|_ or |matplotlibs|_.
- `jupyter `_
- `ipywidgets `_ and
`ipyevents `_, for the ``live()`` viewer of
cameras and SLMs
- The ``images`` extra
Outside Jupyter, ``plt.show()`` blocks; call :func:`slmsuite.configure_plotting` with
``mode="suppress"`` or ``mode="save"`` (and ``headless=True`` without a display).
Use the following to install recommended jupyter-related packages.
.. code-block:: console
pip install -e ".[jupyter]"
All Dependencies
----------------
To install the optional dependencies for GPU, gradients, SLMs, cameras, images, Jupyter,
docs, and testing at once, use the ``dev`` extra.
.. code-block:: console
pip install -e ".[dev]"
.. |slmsuite| replace:: :mod:`slmsuite`
.. _slmsuite: https://github.com/holodyne/slmsuite
.. |autoreload| replace:: ``%autoreload 2``
.. _autoreload: https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html
.. |matplotlibs| replace:: ``%matplotlib inline``
.. _matplotlibs: https://ipython.readthedocs.io/en/stable/interactive/plotting.html