Torch 官網
Torch: Torch website lua: lua website
安裝步驟
Torch can be installed to your home folder in ~/torch by running these three commands:
# in a terminal, run the commands WITHOUT sudo
# installs the basic package dependencies that LuaJIT and Torch require.
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
# installs LuaJIT, LuaRocks, and then uses LuaRocks (the lua package manager)
# to install core packages like torch, nn and paths, as well as a few other packages.
bash install-deps
./install.sh
[NOTE]
-
在使用第一個命令克隆的時候會報以下類似的警告:
Submodule 'pkg/sys' (https://github.com/torch/sys.git) registered for path 'pkg/sys'
[處理辦法]忽略就行..大概意思就是子模塊將被下載后放在相應的位置處..
-
在執行第三條命令之前需要修改
install-deps
文件-
Home -> Torch -> Open
install-deps
-
find the keyword
python-software-properties
and replace it withsoftware-python-common
, save and exit. -
install the software-python-common with the command
sudo apt-get install software-properties-common
-
run the command
cd ~/torch; bash install-deps;
-
-
執行以上命來之后,腳本后自動更新環境變量,你也可以手動進行更新:
source ~/.bashrc
卸載Torch
If you ever need to uninstall torch, simply run the command:
rm -rf ~/torch
檢驗安裝是否成功
Once installed you can run torch with the command th
from you prompt!
這樣你就可以在這個交互窗口內學習和使用Torch.
[補充] install torch with Lua 5.2 instead of LuaJIT
LuaJIT是Lua編程語言的實時編譯器,采用C語言寫的Lua代碼的解釋器。
執行以下命令.
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
# clean old torch installation
./clean.sh
# optional clean command (for older torch versions) 對於老版本的torch,可選清除命來.
# curl -s https://raw.githubusercontent.com/torch/ezinstall/master/clean-old.sh | bash
# https://github.com/torch/distro : set env to use lua
TORCH_LUA_VERSION=LUA52 ./install.sh
# New packages can be installed using Luarocks from the command-line:
# run luarocks WITHOUT sudo
$ luarocks install image
$ luarocks list