nginx - Openresty torch 模块加载问题

标签 nginx lua luajit torch openresty

我正在尝试将 openresty 与 torch 一起用于神经网络的 Rest api。 第一个查询有效,之后的任何查询都失败了。

Nginx 配置

workers processes 1;

error_log logs/error.log;
events {
    workers connections 1024
}
http {
    server {
        listen 5050;
        location /{
            default type text/html;
            content_by_lua_file /home/yiftach/testFile.lua;
        } 
    } 
}

测试文件.lua

require "nn" 
local tensorA=torch.zeros(1,1)
ngx.say(tensorA:size()[1])

错误:

Lua entry thread aborted: runtime error: /home/yiftach/testFile.lua: attempt to index global 'torch' (a nil value)

非常感谢任何帮助

最佳答案

您没有需要 torch 库。 在顶部添加 local torch = require "torch"

关于nginx - Openresty torch 模块加载问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30898411/

相关文章:

c++ - 如何通过导入的目标可传递地设置 “CMAKE_EXE_LINKER_FLAGS”?

node.js - Nginx 删除端口号 :8080 in the url

lua - 将 LuaJIT FFI 结构转换为表

c++ - 为什么 LuaJIT 抛出异常时 std::uncaught_exception 返回 false?

arrays - 向表添加元素时遇到问题(Lua 中的数组)

c - 如何在 lua 中创建接受多个参数的 C 函数?

lua - 如何在 Linux 上超过 64 位 LuaJIT 的 1gb 内存限制?

python - django-allauth:如何修改电子邮件确认网址?

Nginx:limit_conn 与上游 max_conns(在位置上下文中)

docker - 使用 nginx 反向代理的 Go 服务器