安装AutoGluon¶
注意
AutoGluon 需要 Python 版本 3.9、3.10、3.11 或 3.12,并且可在 Linux、MacOS 和 Windows 上使用。
AutoGluon库在所有版本的Amazon SageMaker Distribution中都已预安装。有关更多信息,请参阅本页中的下拉菜单AutoGluon in Amazon SageMaker Studio。
我们建议大多数用户通过pip安装。AutoGluon的pip安装版本是我们积极进行基准测试和测试的版本。 Conda安装可能在安装的依赖项上存在细微差异,这可能会影响性能和稳定性,如果您在使用Conda时遇到问题,我们建议尝试使用pip。
pip install -U pip
pip install -U setuptools wheel
pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
pip install -U pip
pip install -U setuptools wheel
pip install autogluon
# Install UV package installer (faster than pip)
pip install -U uv
# Install AutoGluon
python -m uv pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
# Install UV package installer (faster than pip)
pip install -U uv
# Install AutoGluon with GPU support
python -m uv pip install autogluon
conda create -n ag python=3.10
conda activate ag
conda install -c conda-forge mamba
mamba install -c conda-forge autogluon
mamba install -c conda-forge "ray-tune >=2.10.0,<2.32" "ray-default >=2.10.0,<2.32" # install ray for faster training
conda create -n ag python=3.11
conda activate ag
conda install -c conda-forge mamba
mamba install -c conda-forge autogluon "pytorch=*=cuda*"
mamba install -c conda-forge "ray-tune >=2.10.0,<2.32" "ray-default >=2.10.0,<2.32" # install ray for faster training
pip install uv
python -m uv pip install -U torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu
git clone https://github.com/autogluon/autogluon
cd autogluon && ./full_install.sh
git clone https://github.com/autogluon/autogluon
cd autogluon && ./full_install.sh
MacOS 上的 LightGBM 支持 (LibOMP)
AutoGluon 依赖的 LightGBM 使用 libomp 进行多线程处理。如果你通过 brew install libomp 安装 libomp,可能会因为库版本不兼容而导致段错误。请使用以下命令安装兼容的版本:
# Uninstall libomp if it was previous installed
brew uninstall -f libomp
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
brew install libomp.rb
rm libomp.rb
pip install -U pip
pip install -U setuptools wheel
pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
警告
macOS 上尚不支持 GPU 使用,请使用 Linux 或 Windows 以在 AutoGluon 中利用 GPU。
MacOS 上的 LightGBM 支持 (LibOMP)
AutoGluon 依赖的 LightGBM 使用 libomp 进行多线程处理。如果你通过 brew install libomp 安装 libomp,可能会因为库版本不兼容而导致段错误。使用以下命令安装兼容版本:
# Uninstall libomp if it was previous installed
brew uninstall -f libomp
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
brew install libomp.rb
rm libomp.rb
# Install UV package installer (faster than pip)
pip install -U uv
# Install AutoGluon
python -m uv pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
警告
macOS 上尚不支持 GPU 使用,请使用 Linux 或 Windows 在 AutoGluon 中利用 GPU。
conda create -n ag python=3.11
conda activate ag
conda install -c conda-forge mamba
mamba install -c conda-forge autogluon
警告
macOS 上尚不支持 GPU 使用,请使用 Linux 或 Windows 在 AutoGluon 中利用 GPU。
MacOS 上的 LightGBM 支持 (LibOMP)
AutoGluon 依赖的 LightGBM 使用 libomp 进行多线程处理。如果你通过 brew install libomp 安装 libomp,可能会因为库版本不兼容而导致段错误。使用以下命令安装兼容的版本:
# Uninstall libomp if it was previous installed
brew uninstall -f libomp
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
brew install libomp.rb
rm libomp.rb
pip install -U pip
pip install -U setuptools wheel
git clone https://github.com/autogluon/autogluon
cd autogluon && ./full_install.sh
警告
macOS 上尚不支持 GPU 使用,请使用 Linux 或 Windows 在 AutoGluon 中利用 GPU。
注意
如果您在Windows上安装AutoGluon时遇到困难,请在此GitHub Issue中提供详细信息。
要在Windows上安装AutoGluon,建议使用Anaconda:
-
如果已经安装了Anaconda但版本较旧,请按照此指南进行更新
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 -y
conda activate myenv
继续使用上面创建的conda环境完成剩余的安装步骤
pip install -U pip
pip install -U setuptools wheel
pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
注意
如果您在Windows上安装AutoGluon时遇到困难,请在此GitHub Issue中提供详细信息。
要在Windows上安装AutoGluon,建议使用Anaconda:
-
如果已经安装了Anaconda但版本较旧,请按照此指南进行更新
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 cudatoolkit=11.3 -y
conda activate myenv
通过遵循PyTorch 安装文档(推荐)安装适当的 GPU PyTorch 版本。或者,使用以下命令:
pip install torchvision==0.19.1 --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
通过Python测试来验证您的安装是否有效,并能够检测到您的GPU:
import torch
print(torch.cuda.is_available()) # Should be True
print(torch.cuda.device_count()) # Should be > 0
继续使用上面创建的conda环境完成剩余的安装步骤
pip install -U pip
pip install -U setuptools wheel
pip install autogluon
注意
If you run into difficulties installing AutoGluon on Windows, please provide details in this GitHub Issue.
要在Windows上安装AutoGluon,建议使用Anaconda:
-
If Anaconda is already installed but is an old version, follow this guide to update
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 -y
conda activate myenv
继续使用上面创建的conda环境完成剩余的安装步骤
# Install UV package installer (faster than pip)
pip install -U uv
# Install AutoGluon
python -m uv pip install autogluon --extra-index-url https://download.pytorch.org/whl/cpu
注意
If you run into difficulties installing AutoGluon on Windows, please provide details in this GitHub Issue.
要在Windows上安装AutoGluon,建议使用Anaconda:
-
If Anaconda is already installed but is an old version, follow this guide to update
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 cudatoolkit=11.3 -y
conda activate myenv
通过遵循PyTorch 安装文档(推荐)安装适当的 GPU PyTorch 版本。或者,使用以下命令:
pip install torchvision==0.19.1 --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
通过Python测试来验证您的安装是否有效,并能够检测到您的GPU:
import torch
print(torch.cuda.is_available()) # Should be True
print(torch.cuda.device_count()) # Should be > 0
继续使用上面创建的conda环境完成剩余的安装步骤
# Install UV package installer (faster than pip)
pip install -U uv
# Install AutoGluon with GPU support
python -m uv pip install autogluon
conda create -n ag python=3.10
conda activate ag
conda install -c conda-forge mamba
mamba install -c conda-forge autogluon
mamba install -c conda-forge "ray-tune >=2.10.0,<2.32" "ray-default >=2.10.0,<2.32" # install ray for faster training
conda create -n ag python=3.11
conda activate ag
conda install -c conda-forge mamba
mamba install -c conda-forge -c pytorch -c nvidia autogluon "pytorch=*=*cuda*"
mamba install -c conda-forge "ray-tune >=2.10.0,<2.32" "ray-default >=2.10.0,<2.32" # install ray for faster training
注意
If you run into difficulties installing AutoGluon on Windows, please provide details in this GitHub Issue.
要在Windows上安装AutoGluon,建议使用Anaconda:
-
If Anaconda is already installed but is an old version, follow this guide to update
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 -y
conda activate myenv
继续使用上面创建的conda环境完成剩余的安装步骤
pip install uv
python -m uv pip install -U torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu
git clone https://github.com/autogluon/autogluon
cd autogluon && ./full_install.sh
注意
If you run into difficulties installing AutoGluon on Windows, please provide details in this GitHub Issue.
要在Windows上安装AutoGluon,建议使用Anaconda:
-
If Anaconda is already installed but is an old version, follow this guide to update
打开 Anaconda 提示符 (anaconda3)
在Anaconda Prompt中,执行以下操作:
conda create -n myenv python=3.11 cudatoolkit=11.3 -y
conda activate myenv
通过遵循PyTorch 安装文档(推荐)安装适当的 GPU PyTorch 版本。或者,使用以下命令:
pip install torchvision==0.19.1 --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
通过Python测试来验证您的安装是否有效,并能够检测到您的GPU:
import torch
print(torch.cuda.is_available()) # Should be True
print(torch.cuda.device_count()) # Should be > 0
继续使用上面创建的conda环境完成剩余的安装步骤
git clone https://github.com/autogluon/autogluon
cd autogluon && ./full_install.sh
Install specific AutoGluon modules and dependencies
AutoGluon 被模块化为专门用于表格、多模态或时间序列数据的子模块。您可以通过仅安装特定的子模块来减少所需的依赖项数量:pip install ,其中 可能是以下选项之一:
autogluon.tabular- 用于表格数据的功能 (TabularPredictor)autogluon.tabular的默认独立安装是一个骨架安装。通过
pip install autogluon.tabular[all]安装,以获得与通过pip install autogluon相同的表格安装可用的可选依赖项:
lightgbm,catboost,xgboost,fastai,ray。这些包含在all中。未包含在
all中的可选依赖项:tabpfn,vowpalwabbit,imodels,skex,skl2onnx。要仅使用可选的LightGBM和CatBoost模型运行
autogluon.tabular,例如,你可以执行:pip install autogluon.tabular[lightgbm,catboost]可选依赖项:
skex。这将使KNN模型在CPU上的训练和推理速度提高25倍。使用pip install autogluon.tabular[all,skex]来启用。注意:与ARM处理器不兼容。实验性可选依赖项:
tabpfn。这将启用TabPFN模型的使用,并允许您在TabularPredictor中拟合TabPFN。使用pip install autogluon.tabular[all,tabpfn]来启用。可选依赖项:
vowpalwabbit。这将安装VowpalWabbit包,并允许您在TabularPredictor中拟合VowpalWabbit。实验性可选依赖:
imodels。这将安装imodels包,并允许您在TabularPredictor中拟合可解释的模型。可选依赖项:
skl2onnx。这将通过predictor.compile()在支持的模型上启用ONNX模型编译。
autogluon.multimodal- 用于图像、文本和多模态问题的功能。专注于深度学习模型。要尝试使用
MultiModalPredictor的对象检测功能,请通过mim install "mmcv==2.1.0"、pip install "mmdet==3.2.0"和pip install pycocotools安装额外的依赖项。请注意,Windows用户还应通过pip install pycocotools-windows安装pycocotools,但它仅支持python 3.6/3.7/3.8。
autogluon.timeseries- 仅适用于时间序列数据的功能(TimeSeriesPredictor)。autogluon.common- 辅助功能。单独使用无意义。autogluon.core- 仅包含核心功能(Searcher/Scheduler),适用于任意代码/模型的超参数调优。autogluon.features- 仅用于特征生成/特征预处理管道的功能(主要与表格数据相关)。autogluon.eda- (已弃用)仅用于探索性数据分析的功能。
要从源代码安装子模块,请按照安装整个包的源代码的说明操作,但将行cd autogluon && ./full_install.sh替换为cd autogluon && pip install -e {SUBMODULE_NAME}/{OPTIONAL_DEPENDENCIES}
例如,要从源代码安装
autogluon.tabular[lightgbm,catboost],命令将是:cd autogluon && pip install -e tabular/[lightgbm,catboost]
要安装所有AutoGluon的可选依赖项:
pip install autogluon && pip install autogluon.tabular[tabpfn,vowpalwabbit,imodels,skex,skl2onnx]
AutoGluon in Amazon SageMaker Studio
Amazon SageMaker Distribution 是用于数据科学的 Docker 环境,作为 JupyterLab 笔记本实例和 Code Editor 在 Amazon SageMaker Studio 中的默认镜像。AutoGluon 库在所有版本的 Amazon SageMaker Distribution 中都已预安装。SageMaker Studio 用户可以访问 AutoGluon 的自动化功能,而无需安装任何额外的内容。
要查找SageMaker Distribution镜像中可用的AutoGluon和PyTorch版本,请参考SageMaker Distribution GitHub仓库中您镜像版本的RELEASE.md文件。
Install from source for a specific pull-request
要从源代码构建AutoGluon以测试拉取请求,您可以按照以下说明克隆并安装确切的分支。 如果您是代码审查员或想测试PR是否修复了您报告的bug,此过程非常有用。
在这个例子中,我们使用了这个PR。
它来自用户innixma,PR分支名为accel_preprocess_bool。
这些信息直接在PR页面的标题下方提供(那里写着into autogluon:master from Innixma:accel_preprocess_bool)。
# Edit these two variables to change which PR / branch is being installed
GITHUB_USER=innixma
BRANCH=accel_preprocess_bool
pip install -U pip
git clone --depth 1 --single-branch --branch ${BRANCH} --recurse-submodules https://github.com/${GITHUB_USER}/autogluon.git
cd autogluon && ./full_install.sh
请注意,上述示例仅在分支仍然存在时有效。用户可以在PR合并后删除分支,因此此建议主要针对未合并的PR。
Install nightly builds
AutoGluon 提供夜间构建版本,可以使用 --pre 参数进行安装。夜间构建版本包含最新功能,但尚未像稳定版本那样经过严格测试。
pip install -U uv
python -m uv pip install --pre autogluon
M1 and M2 Apple Silicon
Apple Silicon 现在通过上面概述的 conda 安装说明得到支持。如果用户的机器支持,conda-forge 将安装 GPU 版本。
Kaggle
AutoGluon 被 Kaggle 社区积极使用。你可以在这里找到数百个使用 AutoGluon 的 Kaggle 笔记本 here。
对于允许在笔记本中访问互联网的Kaggle竞赛,您可以在笔记本的开头通过以下行安装AutoGluon:
!pip install -U autogluon > /dev/null
对于没有互联网访问权限的比赛,您可以通过使用Kaggle社区打包的AutoGluon工件之一以Kaggle数据集的形式获取AutoGluon。
如果在安装AutoGluon后遇到问题,请尝试重新启动notebook运行时以确保内存状态干净。
故障排除
如果您遇到此处未涵盖的安装问题,请创建一个GitHub issue。