Installation#

DeepForest has Windows, Linux, and macOS prebuilt wheels on PyPI. We strongly recommend using uv or a virtualenv to create a clean installation container.

pip install deepforest
uv add deepforest

Source Installation#

DeepForest can alternatively be installed from source using the GitHub repository. This can be done directly using pip or uv.

pip install git+https://github.com/weecology/DeepForest.git
uv add "deepforest @ git+https://github.com/weecology/deepforest"

Or you can clone and install locally.

git clone https://github.com/weecology/DeepForest.git
cd DeepForest
pip install .
git clone https://github.com/weecology/DeepForest.git
cd DeepForest
uv sync --all-extras --dev

Development Installation#

For developers who want to contribute to DeepForest, install the package in development mode with all dependencies:

git clone https://github.com/weecology/DeepForest.git
cd DeepForest
pip install .'[dev,docs]'

Or using uv:

git clone https://github.com/weecology/DeepForest.git
cd DeepForest
uv sync --all-extras --dev

This installs DeepForest in editable mode with development and documentation dependencies.

GPU support#

PyTorch can be run on GPUs to allow faster model training and prediction. DeepForest is a PyTorch Lightning module, which automatically distributes data to available GPUs. If using a release model with training, the module can be moved from CPU to GPU for prediction using the pytorch.to() method.

from deepforest import main
m = main.deepforest()
m.load_model("weecology/deepforest-tree")
print("Current device is {}".format(m.device))
m.to("cuda")
print("Current device is {}".format(m.device))
Current device is cpu
Current device is cuda:0

Distributed multi-GPU prediction outside of the training module is not yet implemented. We welcome pull requests for additional support.