Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决

已经装了不下十台服务器的lua, torch,第一次花了十天,现在总结如下:

 

1、查看cuda版本和cudnn版本

nvcc -V


cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

cudnn 为三个数字连起来就是版本。

2、Ubuntu16.04 安装 torch

git clone https://github.com/torch/distro.git torch --recursive

先下载torch安装包,如果报错没有git,则先安装git   安装命令如下:如果不报错说明已经安装好了,直接下一步:

sudo apt-get install git

Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决_第1张图片

安装好了之后:运行上面那个git 下载程序

 cd torch/
 sudo bash install-deps

Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决_第2张图片

一直到Torch7's dependencies have been installed 出现

sudo ./install.sh

直到问你yes/no的时候,选择yes, 然后更新环境

source ~/.bashrc

 

Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决_第3张图片

说明torch安装完成了。但是并不是经常都能安装好的,之前踩过无数的坑。

 

3、module 'loadcaffe' not found  安装loadcaffe

当运行lua代码的时候,出现了init.lua:389: module 'loadcaffe' not found:No LuaRocks module found for loadcaffe

Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决_第4张图片

上次写到这耽搁了,现在补上:

loadcaffe 这个问题出了很久,网上找过很多答案,都没能解决实际问题,仍然出错如下:

init.lua:389: module 'loadcaffe' not found:No LuaRocks module found for loadcaffe

Ubuntu16.04安装torch loadcaffee luarocks hdf5 libcudnn 一站式解决_第5张图片

最后靠这条命令解决的:

sudo luarocks --from=https://raw.githubusercontent.com/torch/rocks/master/ install loadcaffe

等了两分钟安装好了。

4、luarocks: command not found

当然运行上面安装loadcaffe 的时候会报错:luarocks: command not found,因为没有安装luarocks,直接使用下面命令安装:

sudo apt-get install lua5.1
sudo apt-get install liblua5.1-dev
sudo apt-get install luarocks

5、No LuaRocks module found for hdf5  ubuntu16 torch 安装 hdf5

sudo ~/torch/install/bin/luarocks install hdf5

 

6、error: ‘libcudnn (R5) not found in library path

这个报错常见的可能原因是torch7里原本的默认是cudnn5的版本而现在机子上可能装的是更高的版本比如cudnn7,那么针对cudnn7(小博主现装的是cuda 9, cudnn7),需要下载一个模块,并且编译

git clone https://github.com/soumith/cudnn.torch -b R7
cd cudnn.torch
luarocks make cudnn-scm-1.rockspec

运行完之后可能还是会报错,报错需要libcudnn.so.7, 这个可以去网上找或者/usr/local/cuda-9.0/lib64下面看有没有

如果上面命令也解决不了,仍然需要要libcudnn.so.5  ,我把这两个文件拷贝到百度云,直接拷贝到 /usr/local/cuda/lib64/ 下就好

百度云链接:

 

 

你可能感兴趣的:(ubuntu)