Openresty torch module loading issue

418 views Asked by At

I'm trying to use openresty with torch for a Rest api for a neural network. First query works, any query after that fails.

Nginx Config

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;
        } 
    } 
}

testFile.lua

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

The error:

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

Would appreciate any help

1

There are 1 answers

0
daurnimator On

You didn't require the torch library. Add local torch = require "torch" at the top.