torch的安裝 DenseCap依賴的庫


轉載請注明出處:

http://www.cnblogs.com/darkknightzh/p/5653864.html

參考網址:

http://torch.ch/docs/getting-started.html

http://deepdish.io/2015/02/20/local-torch-installation/

 

160714說明:如果需要使用torch及GraphicsMagick並讀取jpg圖像的話,最好先安裝libjpeg的庫,然后在安裝GraphicsMagick,最后再安裝torch。

因為剛才GraphicsMagick調用jpeg沒有錯誤,但是torch里面的某個模塊又提示找不到libjpeg.so的庫了,之后只能先強制卸載image包:luarocks remove image --force,再重新luarocks install image。之后正常了。。。

 

1. 先安裝luarocks

sudo apt-get install luarocks

 

2. 安裝torch

http://torch.ch/docs/getting-started.html

1) 終端中輸入:

git clone https://github.com/torch/distro.git ~/torch --recursive cd ~/torch; bash install-deps; ./install.sh

說明: ~/torch應該就是終端當前所在的文件夾(默認時為/home/XXX/,加了~/torch后就變成了/home/XXX/torch)

2) 將torch添加到PATH中

source ~/.bashrc

160713說明:今天在另一台電腦上安裝了torch7和ZeroBrane,啟動ZeroBrane后,程序第一句require 'image'就錯誤,提示找不到image包。后來網上搜了一下,也有人遇到了這個問題。主要就是環境變量

http://deepdish.io/2015/02/20/local-torch-installation/說了,可以將以下語句加入到~/.bashrc中:

export TORCH_DIR=$HOME/torch
export LUA_PATH="$TORCH_DIR/install/share/lua/5.1/?.lua;$TORCH_DIR/install/share/lua/5.1/?/init.lua;$TORCH_DIR/install/share/luajit-2.1.0-alpha/?.lua" export LUA_CPATH="$TORCH_DIR/install/lib/lua/5.1/?.so"

自己發現,執行完source ~/.bashrc后,~/.bashrc中多了一條語句:

. /home/XXX/program/torch/install/bin/torch-activate

這條語句中torch-activate就是包含torch安裝的庫目錄的文件。然后重啟電腦,再使用ZeroBrane的話,就不會提示找不到image包了。。。

由於沒有重啟電腦,害的我卸了torch又重新裝了幾次。。。哎。。。

現在感覺,如果再碰到這個問題,實在不行的話,就自己手動把torch-activate文件的路徑加到.bashrc中,然后重啟電腦試試。不行的話,額,不行再想辦法吧。。。

3) 如果需要的話,卸載torch

rm -rf ~/torch

 

說明:上面安裝的是torch和LuaJIT,如果希望安裝torch和Lua5.2,而不是LuaJIT,則:

復制代碼
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) # 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
復制代碼

5) 安裝完torch后輸入th:

3. 安裝torch的包(packages),如nndpnn

說明:安裝先安裝nn,再安裝dpnn

1) 下載nn和dpnn:

https://github.com/torch/nn

https://github.com/nicholas-leonard/dpnn

2) 解壓這兩個文件夾。

3) 終端中cd到這兩個文件夾上一級目錄。

4) 使用luarocks install命令進行安裝

luarocks install nn-master/rocks/nn-scm-1.rockspec luarocks install dpnn-master/rocks/dpnn-scm-1.rockspec

說明:① 官網中說直接使用命令luarocks install dpnn進行安裝,但是會提示:

No results matching query were found

② nn和dpnn都有依賴的包,需要先安裝好。具體都有啥,忘了。。。不過dpnn依賴的比nn多。

③ 官網說可以使用Luarocks在終端中安裝packages,比如:

luarocks install image

但是如果安裝失敗的話,就按照3中①-④的步驟,先下載下來,然后再安裝。。。

④ 查看都安裝了哪些包:

luarocks list


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM