实用程序¶
这包含开箱即用的 TorchX 实用程序组件。这些是
仅执行众所周知的二进制文件(例如 )
,并用作教程材料或之间的粘合作
工作流中有意义的阶段。cp
- torchx.components.utils 中。echo(msg: str = 'hello world', image: str = 'ghcr.io/pytorch/torchx:0.1.1dev0', num_replicas: int = 1) → torchx.specs.api.AppDef[来源]¶
将消息回显到 stdout(调用 echo)
- 参数
msg – 消息回声
image – 要使用的图像
num_replicas – 要运行的副本数
- torchx.components.utils 中。touch(文件: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1dev0') → torchx.specs.api.AppDef[来源]¶
触摸文件(调用 touch)
- 参数
file (文件) – 要创建的文件
image – 要使用的镜像
- torchx.components.utils 中。sh(*args: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1dev0', num_replicas: int = 1) → torchx.specs.api.AppDef[来源]¶
通过 sh 运行提供的命令。目前 sh 不支持 环境变量替换。
- 参数
args – bash 参数
image – 要使用的图像
num_replicas – 要运行的副本数
- torchx.components.utils 中。copy(src: str, dst: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1dev0') → torchx.specs.api.AppDef[来源]¶
copy 将文件从 src 复制到 DST。src 和 dst 可以是任何有效的 fsspec url 的 URL 中。
这不支持递归副本或目录。
- 参数
src – 源 fsspec 文件位置
dst – 目标 fsspec 文件位置
image (图像) – 包含 Copy app (复制应用程序) 的图像
- torchx.components.utils 中。python(*args: str, m: 可选[str] = 无, c: 可选[str] = 无,图片: str = 'ghcr.io/pytorch/torchx:0.1.1dev0', 名称: str = 'torchx_utils_python',主机:str = 'aws_t3.medium',num_replicas:int = 1) → torchx.specs.api.AppDef[来源]¶
运行或在指定的 image 和 host 中。用于分隔组件 args 和程序 args (例如
python -c CMD
python -m MODULE
--
torchx run utils.python --m foo.main -- --args to --main
)- 参数
args – 在 sys.argv[1:] 中传递给程序的参数(用 –c 忽略)
m – 将库模块作为脚本运行
c – 作为字符串传递的程序(如果调度器对 args 有长度限制,可能会出错)
image – 要在其上运行的镜像
name (名称) – 任务的名称
host – 已注册的命名资源
num_replicas – 要运行的副本数(每个副本都在自己的容器上)
- 返回
- torchx.components.utils 中。booth(x1: float, x2: float, trial_idx: int = 0, tracker_base: str = '/tmp/torchx-util-booth', image: str = 'ghcr.io/pytorch/torchx:0.1.1dev0') → torchx.specs.api.AppDef[来源]¶
评估 booth 函数 。 输出结果可通过以下方式访问
f(x1, x2) = (x1 + 2*x2 - 7)^2 + (2*x1 + x2 - 5)^2
FsspecResultTracker(outdir)[trial_idx]
- 参数
x1 – x1
x2 – x2
trial_idx – 如果未运行 HPO,则忽略
tracker_base – 跟踪链接的基本输出目录的 URI(例如 s3://foo/bar)
image – 包含 booth 应用程序的映像