1 安裝Torch
本文介紹Torch7的安裝方法,因為本人安裝Torch前安裝了caffe,所以可能CUDA、cudnn、Blas等Torch可能需要用來的庫的安裝就不再重復介紹了,相關依賴出現問題的的猿友可以參考史上最全的caffe安裝過程。
1.1 安裝luarock
lua是通過luarock來進行軟件包管理的,Torch7的接口是lua,因此需要先安裝Lua,本人安裝的是lua52,安裝過程主要參考Torch官方文檔。
1.2 參考官方文檔遇到的問題
記錄參考Torch官方文檔安裝Torch7出現一些問題。
qlua installation
luarocks install qtlua //not qlua
(1) error: found unsuitable Qt version from NOTFOUND, this code requires Qt4.x
solution:
1.exclude anaconda env from your path.
Referrence
2.第二步:
sudo apt-get install qt-sdk
(2) error: module ‘qttorch’ not found: no field package.preload[‘qttorch’] it occur when I use qlua to run some sh
solutions:
luarocks install qttorch
(3) error: readline.h not found
after type ./install.sh , error readline.c:7:31: fatal error: readline/readline.h: No such file or directory #include <readline/readline.h>
solution:
sudo apt-get install libreadline-dev
(4) error: luarocks install image , and occur getting connection timed out for couple of hours
solution:
git clone https://github.com/torch/image.git
cd image
luarocks make image-1.1.alpha-0.rockspec
(5) error: module 'hdf5' not found:No LuaRocks module found for hdf5,
while run the generate heatmap model by type “ th run-hg.lua ../data/tennis jpg”
problem:
luarocks download package through git protocol, which will use ssh protocol. So we have to convert git download protocol to https protocol.
Solotion:
git config –global url.https://.insteadOf ssh://git
vim ~/.gitconfig
To certain .gitconfig like:
[url “https://”]
insteadOf = git://
(最好不要再添加別替換,否則會產生多重替換而我們看不出來。有時候我們在output_log里面看到依然git://github.com,但是這並不一定真實,git://被替換為https://有時候不會顯式出來)
then type:
luarocks install hdf5
#it will print nothing, but running in background.
luarocks intsll hdf5 --verbose
#It will print all the imformation when downloading and compiling.
(6) warning: Failed loading manifest while type ”luarocks list”
Failed loading manifest for /home/werner/.luarocks/lib/luarocks/rocks: ~/.luarocks/lib/luarocks/rocks/manifest: No such file or directory
Solution:
mkdir -p ~/.luarocks/lib/luarocks/rocks
luarocks-admin make-manifest --local-tree --tree=$HOME/.luarocks
(7) error: getrf : Lapack library not found in compile time
solution:
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make NO_AFFINITY=1 USE_OPENMP=1
sudo make install
then:
CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
luarocks install torch
按照以上步驟就能解決問題,網上大多數人都能解決問題。但我們的機器依然報錯。
Reference
后來我查看luarocks install torch輸出發現:
OpenBlas detected
It seems OpenBlas has not been compiled with Lapack support
Then I try:
sudo apt-get install liblapack-dev
reinstall OpenBlas, then I found following information in top output:
OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.
Google it found:
Reference
error OpenBLAS: Detecting fortran compiler failed. Please install fortran compiler, e.g. gfortran, ifort.
So,
sudo apt-get install gfortran
Then reinstall OpenBlas , it resolved.