最近在学习深度学习,首先学习的是torch框架。安装torch可以根据官网,看起来很简单,但是确实会遇到各种困难。
1.Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/ftp.sjtu.edu.cn_ubuntu_dists_precise-security_restricted_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.
这是运行第二步遇到的问题,然后网上提供了一种方法:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
2.ar: strmm_kernel_LN.o: No such file or directorymake[1]: *** [libs] Error 1make[1]: Leaving directory `/tmp/OpenBLAS/kernel'make: *** [libs] Error 1Error. OpenBLAS could not be compiled
在网上找到了一个解决办法
sudo apt-get install vim #安装过vim的忽略此命令
vim ~/torch/install-deps
这时你会看见(15-19行):
if [ $(getconf _NPROCESSORS_CONF) == 1 ]; then
make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0
else
make NO_AFFINITY=1 USE_OPENMP=1
fi
键入i
进入插入模式,在make
语句后面添加BINARY=32
,修改后结果如下:
if [ $(getconf _NPROCESSORS_CONF) == 1 ]; then
make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0 BINARY=32
else
make NO_AFFINITY=1 USE_OPENMP=1 BINARY=32
fi
修改完成后,按下ESC
,键入:wq
保存退出,重新执行bash instal-deps
即可完成安装:
···
Generating OpenBLASConfig.cmake in /opt/OpenBLAS/lib/cmake/openblas
Generating OpenBLASConfigVersion.cmake in /opt/OpenBLAS/lib/cmake/openblas
Install OK!
make[1]: Leaving directory `/tmp/OpenBLAS'
==> Torch7's dependencies have been installed
3.在执行最后一个命令时会出现
make[2]: *** [lib/TH/CMakeFiles/TH.dir/THVector.c.o] Error 1make[1]: *** [lib/TH/CMakeFiles/TH.dir/all] Error 2make: *** [all] Error 2Error: Build error: Failed building.
在网上也可以找到相关的解决办法
gcc版本是gcc-4.8,需要升级至gcc-5:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
gcc升级后,重新执行./install.sh
即可完成安装:
···
Do you want to automatically prepend the Torch install location
to PATH and LD_LIBRARY_PATH in your /home/yang/.bashrc? (yes/no)
[yes] >>>
另外在执行第二步之前先更换一下软件源。