[Torch]的安装

摘要:
1安装Torch本文介绍Torch7的安装方法,因为本人安装Torch前安装了caffe,所以可能CUDA、cudnn、Blas等Torch可能需要用来的库的安装就不再重复介绍了,相关依赖出现问题的的猿友可以参考史上最全的caffe安装过程。

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

reference

(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

reference

(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.

Reference

(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

referrene

(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.

免责声明:文章转载自《[Torch]的安装》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Centos7安装完成后一些小优化Unity3d监听手机暂停与退出事件下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

torch_geometric安装

因为需要跑一些别人的GCN的任务,所以就要安装相关的包; 首先要注意cuda版本和pytorch中的对应关系,必须严格对应,比如我的机器上,cuda版本是10.1; pytorch的cuda版本也是10.1,之前其实是10.2,又重装了一遍; pytorch版本是1.4; python版本是3.6;然后在这个网页上 https://pytorch-ge...

torch笔记合集

Torch笔记 import torch import numpy as np import torch.nn as nn a_np = np.random.rand(10,100) numpy知识回顾 a_np.dtype # 数据类型 a_np.ndim #维度个数 a_np.shape # 形状 整数元祖 a_np.dtype=np.int...

pytorch 基础内容

一些基础的操作: import torch as th a=th.rand(3,4) #随机数,维度为3,4的tensor b=th.rand(4)print(a)print(b) a+b tensor([[0.3777, 0.4128, 0.6244, 0.7772], [0.0859, 0.9350, 0.1705, 0.911...

pytorch的Embedding使用

torch.nn.Embedding存储的是形如num_embeddings*embedding_dim的矩阵,以词向量为例,num_embeddings表示词向量的个数,embedding_dim表示词向量的维度。 初始化: 它提供了从已知Tensor进行初始化的方法:nn.Embedding.from_pretrained 配合torch.from_n...

pytorch导入错误so: undefined symbol: _Z11libshm_initPKc

首先删除torch文件 或者直接卸载 删除会更彻底 https://blog.csdn.net/qq_37674858/article/details/88870124 但是会发现卸载重装pytorch之后 错误信息还在 原因时 conda list 显示包名 存在libtorch 将其卸载 https://blog.csdn.net/pursuit_z...

UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.

内部实则是bool。原: idxs = torch.Tensor(idxs_0.shape[0]).byte() idxs[:] = 1 idxs[idxs_0 < 0] = 0 idxs[idxs_end >= int(N / args.gps_step)] = 0 delta_p_gt = delta...