![](/img/trans.png)
[英]how to set the LUA_PATH and LUA_CPATH for the zerobrane studio in linux
[英]How to set the environment variable of zerobrane studio
以下方法適用於linux平台:
通過在user.lua中添加以下代碼來配置luajit解釋器
path.lua = "your_path/luajit"
通過將以下代碼添加到/opt/zbsstudio/lualibs/mobdebug/mobdebug.lua來配置envrioment變量
package.path = package.path ..'; my_path /?/ init.lua'package.cpath = package.cpath ..'; my_path /?。so'
(這些說明適用於Windows版本的Torch,但這些步驟適用於Linux / OSX版本,假設路徑已修改)。
假設Torch安裝在C:\\Program Files\\Torch
,然后為了讓它作為ZeroBrane Studio(ZBS)的外部解釋器運行,你需要添加path.lua=[[C:\\Program Files\\Torch\\bin\\torch-lua]]
到<ZBS>\\cfg\\user.lua
配置文件。
現在,當您從ZBS( Project | Run
或F6
)執行Lua腳本時,它將在Torch環境中運行:
local torch = require 'torch'
local data = torch.Tensor{
{68, 24, 20},
{74, 26, 21},
{80, 32, 24}
}
print(data)
但是,要使調試在Windows上運行所需的步驟更少(在其他系統上可能不需要這些步驟,但我沒有在那里測試過調試)。 ZBS正在使用luasocket,它是針對lua51.dll
編譯的,但是Torch正在使用libtorch-lua.dll
,因此將luasocket加載到你的(Torch)進程可能會導致崩潰。 要使其工作,您需要構建代理DLL並將其放入Torch/bin
文件夾。
要構建代理DLL,您需要編譯Visual Studio C ++或mingw / gcc,並且可以執行以下步驟:
mkforwardlib.lua
(VS)或mkforwardlib-gcc.lua
(mingw / gcc)腳本。 lua mkforwardlib.lua libtorch-lua lua51 X86
; 如果一切順利,這將在當前文件夾中生成lua51.dll
文件。 lua51.dll
文件復制到Torch\\bin
文件夾。 現在,您應該可以使用Project | Start Debugging
來調試Torch腳本 Project | Start Debugging
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.