在AWS Lambda中运行usd_from_gltf



我试图在AWS Lambda内运行谷歌的usd_from_gltf实用程序,使用自定义Docker映像。设置似乎可以在本地工作,但是当在AWS中执行相同的Lambda时,对于某些输入文件会失败。

最小应用

https://github.com/petrbroz/glb-to-usdz-test

这是一个极简的AWS SAM应用程序,它有一个Lambda函数,名为GlbToUsdzFunction,它从指定的URL下载Glb文件并将其转换为Usdz。Lambda函数使用自定义Docker映像(https://github.com/leon/docker-gltf-to-udsz),并使用Python的subprocess来运行usd_from_gltf工具来处理转换。

示例文件url

  • https://petrbroz.s3.us -西方- 1. - amazonaws.com/glb - - usdz issues/snowmobile.glb
  • https://petrbroz.s3.us -西方- 1. - amazonaws.com/glb - - usdz issues/wall e.glb

本地运行时

两个snowmobile的Lambda函数都成功。Glbwall-e.glb。下面是前者的输出示例:

$ sam build
$ echo "{ "url": "https://petrbroz.s3.us-west-1.amazonaws.com/glb-to-usdz-issues/snowmobile.glb" }" | sam local invoke "GlbToUsdzFunction" --event -
Reading invoke payload from stdin (you can also pass it from file with --event)
Invoking Container created from glbtousdzfunction:glb-to-usdz-lambda
Building image.................
Skip pulling image and use local one: glbtousdzfunction:rapid-1.46.0-x86_64.
START RequestId: 720b6b49-e36c-4429-96fb-9e0e5c02c09b Version: $LATEST
Downloading file
Converting file
Warning: extensionsUsed: Extension is in extensionsUsed but not actually referenced: KHR_texture_transform [GLTF_WARN_EXTENSION_UNREFERENCED]
END RequestId: 720b6b49-e36c-4429-96fb-9e0e5c02c09b
REPORT RequestId: 720b6b49-e36c-4429-96fb-9e0e5c02c09b  Init Duration: 0.22 ms  Duration: 19997.59 ms   Billed Duration: 19998 ms       Memory Size: 1024 MB    Max Memory Used: 1024 MB
{"status": "success"}

在AWS中运行时

snowmobile的Lambda函数成功。Glb但是wall-e.glb失败。下面是后者的输出:

START RequestId: b1bdc496-ec12-430e-a641-2574af354d60 Version: $LATEST
Downloading file
Converting file
ERROR: USD: Insufficient permissions to write to destination directory '/var/tmp' (Replace) [UFG_ERROR_USD]
ERROR: USD: Failed to map '/var/tmp/output.usdc': No such file or directory (AddFile) [UFG_ERROR_USD]
Warning: USD: Failed to add temporary layer at '/var/tmp/output.usdc' to the package at path 'output.usdz'. (_CreateNewUsdzPackage) [UFG_WARN_USD]
ERROR: Cannot write USD: "/tmp/output.usdz" [UFG_ERROR_IO_WRITE_USD]
Command '['usd_from_gltf', '/tmp/input.glb', '/tmp/output.usdz']' returned non-zero exit status 255.
END RequestId: b1bdc496-ec12-430e-a641-2574af354d60
REPORT RequestId: b1bdc496-ec12-430e-a641-2574af354d60  Duration: 2039.96 ms    Billed Duration: 5166 ms    Memory Size: 1024 MB    Max Memory Used: 101 MB Init Duration: 3125.71 ms

有人遇到这个吗?我在这里做错了什么,或者这可能是一个错误在AWS方面,或在usd_from_gltf方面?

一些美元转换导致库编写中间文件,看起来它是为此目的使用/var/tmp构建的。由于Lambdas只能写入/tmp,我们提出的解决方案是将/var/tmp链接到/tmp:在global -to-usdz Dockerfile中,添加RUN rm -rf /var/tmp && ln -s /tmp /var/tmp

一行这允许你的第二个例子成功。

相关内容

  • 没有找到相关文章

最新更新