Skip to content

02 - Installation

Hardware and operating system

Item Embree (CPU) Vulkan (GPU) OptiX (GPU)
Hardware x86_64 CPU NVIDIA, AMD or Intel GPU with Vulkan ray queries NVIDIA GPU
GPU memory — 4 GB or more, 8 GB recommended 4 GB or more, 8 GB recommended
Driver none a recent graphics driver a recent NVIDIA driver
Operating system Windows 10/11, Linux Windows 10/11, Linux Windows 10/11, Linux
Python 3.10–3.13 3.10–3.13 3.10–3.13

Every LESS feature works without a suitable GPU; large simulations are simply slower on the CPU. On NVIDIA hardware OptiX is usually the fastest; AMD and Intel GPUs use Vulkan.

Installing

pip install "less3d==3.1.0"

The package already contains the compute libraries, so no compiler or SDK is needed. For GPU computing you only need the vendor's graphics driver.

Optional components

Some features need extra Python libraries:

Component Used for Installs
lidar Reconstructing scenes from .las/.laz point clouds (chapter 17) laspy, cloth-simulation-filter
atmosphere The 6S atmosphere less.SixSAtmosphere (chapter 16) Py6S
pip install "less3d[lidar]==3.1.0"
pip install "less3d[lidar,atmosphere]==3.1.0"

Checking the installation

import less

print("LESS", less.__version__)
for backend in less.list_backends(probe=True):
    print(backend.name, backend.available, backend.unavailable_reason or "")

A working installation prints something like:

LESS 3.1.0
optix True
embree True
vulkan True

When a backend shows False, the reason follows, for example that no supported GPU was found or that the driver is too old.

Choosing the backend and device

scene = less.Scene()                            # automatic
scene = less.Scene(backend="optix")             # NVIDIA OptiX
scene = less.Scene(backend="vulkan")            # Vulkan
scene = less.Scene(backend="embree")            # CPU
scene = less.Scene(backend="vulkan", device=1)  # second Vulkan device
Parameter Default Meaning
backend "auto" "auto", "optix", "vulkan" or "embree"
device 0 GPU index within the chosen backend

If the requested backend is not available, LESS raises an error with the reason instead of switching to another backend. Choose the backend explicitly when you compare performance or need fixed hardware.

To see which features run on this machine:

print(less.available_features())
print(less.can_use("lidar_waveform", backend="embree"))

Comparing the three backends

import time
import less

def run(backend):
    scene = less.Scene(backend=backend)
    scene.size = 10.0
    scene.terrain = less.Terrain(property=less.Lambertian(reflectance=0.3))
    scene.illumination = less.Illumination(
        source=less.Sun(zenith=30, azimuth=150),
        atmosphere=less.SimpleSpectralAtmosphere(turbidity=2.0))
    sensor = less.OpticalImager(
        less.Orthographic(image_size=256), bands=[650, 550, 450], quality=64)
    scene.simulate(sensor)                 # the first run also builds the scene
    start = time.perf_counter()
    scene.simulate(sensor)
    return time.perf_counter() - start

for name in ("optix", "vulkan", "embree"):
    try:
        print(f"{name}: {run(name) * 1000:.1f} ms")
    except Exception as error:
        print(f"{name}: not available ({error})")

The first run on a given GPU is noticeably slower because the driver compiles the compute programs. The compiled programs are cached in your user directory and reused afterwards. To keep the cache in a fixed place, set the environment variable LESS_CACHE_DIR before starting Python.

Built-in examples

LESS ships with a few complete scenes that are handy for checking an installation:

python -m less.examples autumn_forest
python -m less.examples maize_field

They open the 3-D viewer in your browser (see chapter 6).

Common problems

A GPU backend is reported as unavailable. Run less.list_backends(probe=True) to see why. Usually updating the graphics driver fixes it; AMD and Intel GPUs must also support Vulkan ray queries. NVIDIA users can check the driver with nvidia-smi.

Out of GPU memory. Reduce the number of triangles or the scene extent, close other programs that use the GPU, or use backend="embree".

image.show() does not open a window. matplotlib is using a non-interactive backend. Choose an interactive one at the top of your script:

import matplotlib
matplotlib.use("TkAgg")

If you only need the picture, use image.save("out.png").

Next