Installation¶
Install with pixi (Recommended)¶
Installing segment-geospatial with uv or pip can be challenging on some platforms (especially Windows) due to complicated pytorch/cuda dependencies and numpy version conflicts. Pixi is recommended to avoid these issues, as it provides faster and more reliable dependency resolution than conda or mamba.
1) Install Pixi¶
Linux/macOS (bash/zsh)¶
1 | |
Close and re-open your terminal (or reload your shell) so pixi is on your PATH. Then confirm:
1 | |
Windows (PowerShell)¶
Open PowerShell (preferably as a normal user, Admin not required), then run:
1 | |
Close and re-open PowerShell, then confirm:
1 | |
2) Create a Pixi project¶
Navigate to a directory where you want to create the project and run:
1 2 | |
3) Configure pixi.toml¶
Open pixi.toml in the geo directory and replace its contents with the following depending on your system.
If you have an NVIDIA GPU with CUDA, run nvidia-smi to check the CUDA version.
For GPU with CUDA 12.x:¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
For GPU with CUDA 13.x:¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
For CPU:¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
4) Install the environment¶
From the geo folder:
1 | |
This step may take several minutes on first install depending on your internet connection and system.
5) Verify PyTorch + CUDA¶
If you have an NVIDIA GPU with CUDA, run the following command to verify the PyTorch + CUDA installation:
1 | |
Expected output should be like this:
PyTorch: 2.7.1(or higher)CUDA available: TrueGPU: NVIDIA RTX 4090(your GPU name)
If CUDA is False, check:
nvidia-smiworks in your terminal- NVIDIA driver is up to date
6) Request access to SAM 3 (Optional)¶
To use SAM 3, you will need to request access by filling out this form on Hugging Face at https://huggingface.co/facebook/sam3. Once your request has been approved, run the following command in the terminal to authenticate:
1 | |
After authentication, you can download the SAM 3 model from Hugging Face:
1 | |
Important Note: SAM 3 currently requires an NVIDIA GPU with CUDA support. You won't be able to use SAM 3 if you have a CPU only system (source). You will get an error message like this: Failed to load model: Torch not compiled with CUDA enabled.
7) Start Jupyter Lab¶
To start using segment-geospatial in Jupyter Lab:
1 | |
This will open Jupyter Lab in your default browser. You can now create a new notebook and start using segment-geospatial!
Install from PyPI¶
segment-geospatial is available on PyPI. To install segment-geospatial, run this command in your terminal:
1 | |
Install from conda-forge¶
segment-geospatial is also available on conda-forge. If you have
Anaconda or Miniconda installed on your computer, you can install segment-geospatial using the following commands. It is recommended to create a fresh conda environment for segment-geospatial. The following commands will create a new conda environment named geo and install segment-geospatial and its dependencies:
1 2 3 4 | |
If your system has a GPU, but the above commands do not install the GPU version of pytorch, you can force the installation of the GPU version of pytorch using the following command:
1 | |
Samgeo-geospatial has some optional dependencies that are not included in the default conda environment. To install these dependencies, run the following command:
1 | |
Install from GitHub¶
To install the development version from GitHub using Git, run the following command in your terminal:
1 | |
Use docker¶
You can also use docker to run segment-geospatial:
1 | |
To enable GPU for segment-geospatial, run the following command to run a short benchmark on your GPU:
1 | |
The output should be similar to the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
If you encounter the following error:
1 | |
Try adding sudo to the command:
1 | |
Once everything is working, you can run the following command to start a Jupyter Notebook server:
1 | |