Openresty module loading problem

I am trying to use openresty with torch for Rest api for neural network. The first request works, any request after that fails.

Nginx configuration

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])

      

Mistake:

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

      

Would be grateful for the help

+3


source to share


1 answer


You are not require

torch libraries. Add local torch = require "torch"

at the top.



+1


source







All Articles