Pytorch support

未关闭
#141 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python, pytorch, wasm

调研方向

先从 componentize-py 0.16.0 的编译命令和提供的 strategy.py 开始,然后在 macOS 上的 Python 3.11.10 中重现导入失败。追踪导入 torch 为何会在没有 _ctypes 的情况下到达 ctypes;当报告的 PyTorch 模块能够成功编译,或受支持的限制和所需设置已得到明确记录时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

I introduced the pytorch module. When executing the compilation, the following error was reported. How should I solve this problem?

Building component my-server with `componentize-py -w spin-http componentize my_server -o target/app/my_server.wasm`
Traceback (most recent call last):
  File "/Users/ken/Work/Workspace/spin/myenv/bin/componentize-py", line 8, in <module>
    sys.exit(script())

AssertionError: Traceback (most recent call last):
  File "/0/my_server.py", line 4, in <module>
    from strategy import get_strategy_result
  File "/0/strategy.py", line 1, in <module>
    from torch import tensor
  File "/1/torch/__init__.py", line 14, in <module>
    import ctypes
  File "/python/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

the strategy.py is:

from torch import tensor

def get_strategy_result():
    # Create a tensor
    x = tensor([1.0, 2.0, 3.0])
    # Perform a simple operation
    y = x * 2
    return y
        
if __name__ == "__main__":
    print(get_strategy_result())

The version of componentize-py is 0.16.0
my plantform is MacBook Pro
the version of Python is 3.11.10

主要语言
Rust
星标
284
派生
56
平均合并
2 天 4 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bytecodealliance/componentize-py 的其他 Issue

查看 bytecodealliance/componentize-py 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。