本镜像为官方ExecuTorch Docker镜像,基于openEuler系统构建,由openEuler CloudNative SIG维护。ExecuTorch是PyTorch的统一设备端AI模型部署解决方案,支持从智能手机到微控制器等多种设备,致力于提供隐私保护、高性能和高可移植性的模型部署能力。该镜像可直接用于AI模型的导出、优化和部署,无需手动C++重写或格式转换,适用于研究到生产环境的无缝过渡。
每个ExecuTorch Docker镜像的标签由ExecuTorch版本、基础镜像版本组成,具体信息如下:
| 标签 | 当前版本 | 架构 |
|---|---|---|
| 1.0.0-torch2.9.0-python3.11-oe2403sp2 | 基于openEuler 24.03-LTS-SP2的ExecuTorch 1.0.0 | aarch64 |
支持的设备
使用容器设置环境
bash# 启动ExecuTorch容器 docker run --rm --name executorch -it --entrypoint bash openeuler/executorch:latest
pythonimport torch from executorch.exir import to_edge_transform_and_lower from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner # 1. 导出PyTorch模型 model = MyModel().eval() example_inputs = (torch.randn(1, 3, 224, 224),) exported_program = torch.export.export(model, example_inputs) # 2. 针对目标硬件优化(通过单行代码切换后端) program = to_edge_transform_and_lower( exported_program, partitioner=[XnnpackPartitioner()] # CPU | CoreMLPartitioner()(iOS)| QnnPartitioner()(Qualcomm) ).to_executorch() # 3. 保存部署文件 with open("model.pte", "wb") as f: f.write(program.buffer) # (可选)通过ExecuTorch运行时的pybind API本地测试 from executorch.runtime import Runtime runtime = Runtime.get() method = runtime.load_program("model.pte").load_method("forward") outputs = method.execute([torch.randn(1, 3, 224, 224)])
C++
cpp#include <executorch/extension/module/module.h> #include <executorch/extension/tensor/tensor.h> Module module("model.pte"); auto tensor = make_tensor_ptr({2, 2}, {1.0f, 2.0f, 3.0f, 4.0f}); auto outputs = module.forward(tensor);
Swift(iOS)
swiftimport ExecuTorch let module = Module(filePath: "model.pte") let input = Tensor<Float>([1.0, 2.0, 3.0, 4.0], shape: [2, 2]) let outputs = try module.forward(input)
Kotlin(Android)
kotlinval module = Module.load("model.pte") val inputTensor = Tensor.fromBlob(floatArrayOf(1.0f, 2.0f, 3.0f, 4.0f), longArrayOf(2, 2)) val outputs = module.forward(EValue.from(inputTensor))
使用export_llm脚本或https://github.com/huggingface/optimum-executorch%E5%AF%BC%E5%87%BALlama%E6%A8%A1%E5%9E%8B%EF%BC%9A
bash# 使用export_llm python -m executorch.extension.llm.export.export_llm --model llama3_2 --output llama.pte # 使用Optimum-ExecuTorch optimum-cli export executorch \ --model meta-llama/Llama-3.2-1B \ --task text-generation \ --recipe xnnpack \ --output_dir llama_model
通过LLM运行器API在设备端运行:
C++
cpp#include <executorch/extension/llm/runner/text_llm_runner.h> auto runner = create_llama_runner("llama.pte", "tiktoken.bin"); executorch::extension::llm::GenerationConfig config{ .seq_len = 128, .temperature = 0.8f}; runner->generate("Hello, how are you?", config);
Swift(iOS)
swiftimport ExecuTorchLLM let runner = TextRunner(modelPath: "llama.pte", tokenizerPath: "tiktoken.bin") try runner.generate("Hello, how are you?", Config { $0.sequenceLength = 128 }) { token in print(token, terminator: "") }
Kotlin(Android)
API文档 • https://github.com/meta-pytorch/executorch-examples/tree/main/llm/android/LlamaDemo
kotlinval llmModule = LlmModule("llama.pte", "tiktoken.bin", 0.8f) llmModule.load() llmModule.generate("Hello, how are you?", 128, object : LlmCallback { override fun onResult(result: String) { print(result) } override fun onStats(stats: String) { } })
对于多模态模型(视觉、音频),可使用MultiModal运行器API,该API扩展了LLM运行器以处理文本之外的图像和音频输入。详见Llava和Voxtral示例。
完整工作流(包括量化、移动部署和高级选项)请参见examples/models/llama。
如有任何问题或需要使用特定功能,请在openeuler-docker-images提交issue或pull request。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务