Reputation: 6247
I install all torch package into my local file torch-distro(Followed by this tutorial). I want to use Zerobrane
to debug my code. Zerobrane
can't find my local path of torch. How Can I set my local path to the Zerobrane
environment variable.
I tried to add path.lua = "${prefix}/torch-distro/install/bin/luajit" into the user.lua. But it can't work
Upvotes: 4
Views: 3415
Reputation: 6247
Following method works on linux platform:
Configuring the luajit interpreter by adding following code into the user.lua
path.lua = "your_path/luajit"
Configuring the envrioment variable by adding following code into the /opt/zbsstudio/lualibs/mobdebug/mobdebug.lua
package.path = package.path .. ';my_path/?/init.lua' package.cpath = package.cpath .. ';my_path/?.so'
Upvotes: 2
Reputation: 26774
(These instructions are for the Windows version of Torch, but the steps should work for Linux/OSX versions assuming the paths are modified).
Let's say the Torch is installed in C:\Program Files\Torch
, then to get it running as the external interpreter from ZeroBrane Studio (ZBS), you need to add path.lua=[[C:\Program Files\Torch\bin\torch-lua]]
to <ZBS>\cfg\user.lua
configuration file.
Now, when you execute a Lua script from ZBS (Project | Run
or F6
), it will run inside the Torch environment:
local torch = require 'torch'
local data = torch.Tensor{
{68, 24, 20},
{74, 26, 21},
{80, 32, 24}
}
print(data)
However, there are few more steps required to get the debugging to work on Windows (these steps are likely not be needed on other systems, but I haven't tested debugging there). ZBS is using luasocket, which is compiled against lua51.dll
, but Torch is using libtorch-lua.dll
, so loading luasocket into your (Torch) process is likely to crash it. To make it work, you need to build a proxy DLL and put it into your Torch/bin
folder.
To build the proxy DLL, you will need Visual Studio C++ or mingw/gcc compiled and can follow these steps:
mkforwardlib.lua
(VS) or mkforwardlib-gcc.lua
(mingw/gcc) script from Lua Proxy DLL3 page.lua mkforwardlib.lua libtorch-lua lua51 X86
; if everything goes well, this will produce lua51.dll
file in the current folder.lua51.dll
file to Torch\bin
folder.Now you should be able to debug Torch scripts by using Project | Start Debugging
.
Upvotes: 0