Ludwig 与 Docker
您也可以使用 dockerhub 上提供的 docker 镜像来运行 Ludwig。这些镜像包含了支持 Ludwig 功能的完整预安装包。
仓库¶
以下仓库包含从 master
分支构建的具有完整功能的 Ludwig 版本。
ludwigai/ludwig
打包了 PyTorch 的 Ludwigludwigai/ludwig-gpu
打包了支持 GPU 版本的 PyTorch 的 Ludwigludwigai/ludwig-ray
打包了 PyTorch 和 2.2 版本 ray-project/ray 的 Ludwigludwigai/ludwig-ray-gpu
打包了支持 GPU 版本的 PyTorch 和 2.2 版本 ray-project/ray 的 Ludwig
镜像标签¶
以下是拉取和运行 docker 镜像时可以使用的镜像标签。
master
- 从 Ludwig 的master
分支构建nightly
- Ludwig 软件的夜间构建版本。sha-<提交点>
- Ludwig 软件在指定 git sha1 7 字符提交点的版本。
运行容器¶
以下是使用 ludwigai/ludwig:master
镜像的一些示例,用于
- 运行
ludwig cli
命令,或 - 运行包含 Ludwig api 的 Python 程序,或
- 使用 Tensorboard 查看 Ludwig 结果
为了示例的目的,假设以下宿主机目录结构
/top/level/directory/path/
data/
train.csv
src/
config.yaml
ludwig_api_program.py
运行 Ludwig CLI¶
# set shell variable to parent directory
parent_path=/top/level/directory/path
# invoke docker run command to execute the ludwig cli
# map host directory ${parent_path}/data to container /data directory
# map host directory ${parent_path}/src to container /src directory
docker run -v ${parent_path}/data:/data \
-v ${parent_path}/src:/src \
ludwigai/ludwig:master \
experiment --config /src/config.yaml \
--dataset /data/train.csv \
--output_directory /src/results
实验结果可在宿主机目录 /top/level/directory/path/src/results
中找到
使用 Ludwig API 运行 Python 程序¶
# set shell variable to parent directory
parent_path=/top/level/directory/path
# invoke docker run command to execute Python interpreter
# map host directory ${parent_path}/data to container /data directory
# map host directory ${parent_path}/src to container /src directory
# set current working directory to container /src directory
# change default entrypoint from ludwig to python
docker run -v ${parent_path}/data:/data \
-v ${parent_path}/src:/src \
-w /src \
--entrypoint python \
ludwigai/ludwig:master /src/ludwig_api_program.py
Ludwig 结果可在宿主机目录 /top/level/directory/path/src/results
中找到