Install GTSAM 4.3
Use the official Python wheels for the shortest path, or build the C++17 library from the tagged source release. Both routes below end with a working factor graph.
Install the Python package
PyPI provides official GTSAM 4.3.0 wheels for CPython 3.11 through 3.14 on Linux x86-64, Linux ARM64, and macOS universal2.
python3 -m venv .venv-gtsam
source .venv-gtsam/bin/activate
python -m pip install --upgrade pip
python -m pip install "gtsam==4.3.0"
python -c "from importlib.metadata import version; print(version('gtsam'))"
4.3.0What this installs
- The Python API and compiled GTSAM library
- Core nonlinear, linear, discrete, hybrid, navigation, SLAM, SFM, constrained, and certifiable modules
- No local C++ compilation on supported wheel platforms
Use Python 3.11–3.14. If a suitable virtual or conda environment is already active, skip the environment-creation and activation commands. On Debian/Ubuntu, install the matching python3-venv package if venv is unavailable.
For unreleased changes from develop, use python -m pip install gtsam-develop in a separate environment. Development wheels can change between builds.
gtsam.cuda. You must compile GTSAM and its Python wrapper on a CUDA-equipped machine. Follow the CUDA Python build recipe; installing the CUDA toolkit alone does not add bindings to an existing wheel.Build the tagged source release
Use the 4.3.0 tag for a reproducible build. Install Git, a C++17 toolchain, and CMake 3.16 or newer first. This recipe disables the optional Boost features and installs to a user-writable prefix.
git clone --branch 4.3.0 --depth 1 https://github.com/borglab/gtsam.git
cd gtsam
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$HOME/.local" \
-DGTSAM_USE_BOOST_FEATURES=OFF \
-DGTSAM_ENABLE_BOOST_SERIALIZATION=OFF
cmake --build build --parallel 6
cmake --build build --target install
cmake --build build --target Pose2SLAMExample --parallel 6
./build/examples/Pose2SLAMExample
Continuously tested toolchains
- Linux
- GCC 11, 13–15; Clang 11, 14, 16
- macOS
- Xcode 16
- Windows
- MSVC toolset 14.40
- Build system
- CMake ≥ 3.16
Older C++17-capable toolchains may work but are not continuously tested.
The C++ example prints a five-pose factor graph, its optimized poses, and marginal covariances. See Pose2SLAMExample.cpp for the source. This C++ build does not install Python bindings; the next section is for the Python installation route.
See the CUDA Python build recipe or the complete build page for TBB, MKL, install prefixes, MATLAB, and platform details.
Run a first factor graph in Python
This small Pose2 problem anchors one pose, adds an odometry measurement, and estimates the second pose from deliberately perturbed initial values.
import gtsam
from gtsam.symbol_shorthand import X
graph = gtsam.NonlinearFactorGraph()
prior_noise = gtsam.noiseModel.Diagonal.Sigmas([0.3, 0.3, 0.1])
odom_noise = gtsam.noiseModel.Diagonal.Sigmas([0.2, 0.2, 0.1])
graph.add(gtsam.PriorFactorPose2(X(0), gtsam.Pose2(), prior_noise))
graph.add(gtsam.BetweenFactorPose2(
X(0), X(1), gtsam.Pose2(2.0, 0.0, 0.0), odom_noise
))
initial = gtsam.Values()
initial.insert(X(0), gtsam.Pose2(0.2, -0.1, 0.05))
initial.insert(X(1), gtsam.Pose2(2.3, 0.2, -0.05))
result = gtsam.LevenbergMarquardtOptimizer(graph, initial).optimize()
print(result.atPose2(X(1)))
- VariablesTwo robot poses on SE(2)
- FactorsA prior and a relative-pose measurement
- ResultThe optimizer returns a
Valuesestimate near (2, 0, 0)
Continue with a worked example
Choose the notebook closest to your problem. The 4.3 documentation includes 328 notebooks across worked examples and module API guides; not every notebook is a standalone executable example. Some need optional dependencies or a custom build.
Choose a package source deliberately
4.3.0You need C++, MATLAB, CUDA, Windows, or custom build options.GTSAM projectRelease →gtsam-developYou need an unreleased fix and can tolerate API changes.GTSAM projectNightlies →Three build and API changes to check
C++17 is required
Move downstream projects to a C++17-capable toolchain before adopting 4.3.
Boost is optional
Core builds can omit Boost, but the two Boost feature flags default to ON in ordinary CMake builds.
Audit deprecated APIs
Configure with GTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF to find APIs scheduled for removal after 4.3.