Summary on deep learning framework --- Torch7 

2018-07-22 21:30:28

1. 尝试第一个 CNN 的 torch版本, 代码如下:

  

  1. -- We now have 5 steps left to do in training our first torch neural network
  2. -- 1. Load and normalize data
  3. -- 2. Define Neural Network
  4. -- 3. Define Loss function
  5. -- 4. Train network on training data
  6. -- 5. Test network on test data.
  7.  
  8. -- 1. Load and normalize data
  9. require 'paths'
  10. require 'image';
  11. if (not paths.filep("cifar10torchsmall.zip")) then
  12. os.execute('wget -c https://s3.amazonaws.com/torch7/data/cifar10torchsmall.zip')
  13. os.execute('unzip cifar10torchsmall.zip')
  14. end
  15. trainset = torch.load('cifar10-train.t7')
  16. testset = torch.load('cifar10-test.t7')
  17. classes = {'airplane', 'automobile', 'bird', 'cat',
  18. 'deer', 'dog', 'frog', 'horse', 'ship', 'truck'}
  19.  
  20. print(trainset)
  21. print(#trainset.data)
  22.  
  23. itorch.image(trainset.data[]) -- display the 100-th image in dataset
  24. print(classes[trainset.label[]])
  25.  
  26. -- ignore setmetatable for now, it is a feature beyond the scope of this tutorial.
  27. -- It sets the index operator
  28. setmetatable(trainset,
  29. {__index = function(t, i)
  30. return {t.data[i], t.label[i]}
  31. end}
  32. );
  33. trainset.data = trainset.data:double() -- convert the data from a ByteTensor to a DoubleTensor.
  34.  
  35. function trainset:size()
  36. return self.data:size()
  37. end
  38.  
  39. print(trainset:size())
  40. print(trainset[])
  41. itorch.image(trainset[][])
  42.  
  43. redChannel = trainset.data[{ {}, {}, {}, {} }] -- this pick {all images, 1st channel, all vertical pixels, all horizontal pixels}
  44. print(#redChannel)
  45.  
  46. -- TODO:fill
  47. mean = {}
  48. stdv = {}
  49. for i = , do
  50. mean[i] = trainset.data[{ {}, {i}, {}, {} }]:mean() -- mean estimation
  51. print('Channel ' .. i .. ' , Mean: ' .. mean[i])
  52. trainset.data[{ {}, {i}, {}, {} }]:add(-mean[i]) -- mean subtraction
  53.  
  54. stdv[i] = trainset.data[ { {}, {i}, {}, {} }]:std() -- std estimation
  55. print('Channel ' .. i .. ' , Standard Deviation: ' .. stdv[i])
  56. trainset.data[{ {}, {i}, {}, {} }]:div(stdv[i]) -- std scaling
  57. end
  58.  
  59. -- 2. Define Neural Network
  60. net = nn.Sequential()
  61. net:add(nn.SpatialConvolution(, , , )) -- 3 input image channels, 6 output channels, 5x5 convolution kernel
  62. net:add(nn.ReLU()) -- non-linearity
  63. net:add(nn.SpatialMaxPooling(,,,)) -- A max-pooling operation that looks at 2x2 windows and finds the max.
  64. net:add(nn.SpatialConvolution(, , , ))
  65. net:add(nn.ReLU()) -- non-linearity
  66. net:add(nn.SpatialMaxPooling(,,,))
  67. net:add(nn.View(**)) -- reshapes from a 3D tensor of 16x5x5 into 1D tensor of 16*5*5
  68. net:add(nn.Linear(**, )) -- fully connected layer (matrix multiplication between input and weights)
  69. net:add(nn.ReLU()) -- non-linearity
  70. net:add(nn.Linear(, ))
  71. net:add(nn.ReLU()) -- non-linearity
  72. net:add(nn.Linear(, )) -- 10 is the number of outputs of the network (in this case, 10 digits)
  73. net:add(nn.LogSoftMax()) -- converts the output to a log-probability. Useful for classification problems
  74.  
  75. -- 3. Let us difine the Loss function
  76. criterion = nn.ClassNLLCriterion()
  77.  
  78. -- 4. Train the neural network
  79. trainer = nn.StochasticGradient(net, criterion)
  80. trainer.learningRate = 0.001
  81. trainer.maxIteration = -- just do 5 epochs of training.
  82. trainer:train(trainset)
  83.  
  84. -- 5. Test the network, print accuracy
  85. print(classes[testset.label[]])
  86. itorch.image(testset.data[])
  87.  
  88. testset.data = testset.data:double() -- convert from Byte tensor to Double tensor
  89. for i=, do -- over each image channel
  90. testset.data[{ {}, {i}, {}, {} }]:add(-mean[i]) -- mean subtraction
  91. testset.data[{ {}, {i}, {}, {} }]:div(stdv[i]) -- std scaling
  92. end
  93.  
  94. -- for fun, print the mean and standard-deviation of example-100
  95. horse = testset.data[]
  96. print(horse:mean(), horse:std())
  97.  
  98. print(classes[testset.label[]])
  99. itorch.image(testset.data[])
  100. predicted = net:forward(testset.data[])
  101.  
  102. -- the output of the network is Log-Probabilities. To convert them to probabilities, you have to take e^x
  103. print(predicted:exp())
  104.  
  105. for i=,predicted:size() do
  106. print(classes[i], predicted[i])
  107. end
  108.  
  109. -- test the accuracy
  110. correct =
  111. for i=, do
  112. local groundtruth = testset.label[i]
  113. local prediction = net:forward(testset.data[i])
  114. local confidences, indices = torch.sort(prediction, true) -- true means sort in descending order
  115. if groundtruth == indices[] then
  116. correct = correct +
  117. end
  118. end
  119.  
  120. print(correct, *correct/ .. ' % ')
  121.  
  122. class_performance = {, , , , , , , , , }
  123. for i=, do
  124. local groundtruth = testset.label[i]
  125. local prediction = net:forward(testset.data[i])
  126. local confidences, indices = torch.sort(prediction, true) -- true means sort in descending order
  127. if groundtruth == indices[] then
  128. class_performance[groundtruth] = class_performance[groundtruth] +
  129. end
  130. end
  131.  
  132. for i=,#classes do
  133. print(classes[i], *class_performance[i]/ .. ' %')
  134. end
  135.  
  136. require 'cunn';
  137. net = net:cuda()
  138. criterion = criterion:cuda()
  139. trainset.data = trainset.data:cuda()
  140. trainset.label = trainset.label:cuda()
  141.  
  142. trainer = nn.StochasticGradient(net, criterion)
  143. trainer.learningRate = 0.001
  144. trainer.maxIteration = -- just do 5 epochs of training.
  145.  
  146. trainer:train(trainset)

  

    那么,运行起来 却出现如下的问题:

  (1).

/home/wangxiao/torch/install/bin/luajit: ./train_network.lua:26: attempt to index global 'itorch' (a nil value)
stack traceback:
./train_network.lua:26: in main chunk
[C]: in function 'dofile'
...xiao/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670
wangxiao@AHU:~/Documents/Lua test examples$

    主要是 itorch 的问题, 另外就是 要引用 require 'nn' 来解决 无法辨别 nn 的问题.

  我是把 带有 itorch 的那些行都暂时注释了.

2.  'libcudnn (R5) not found in library path.

wangxiao@AHU:~/Downloads/wide-residual-networks-master$ th ./train_Single_Multilabel_Image_Classification.lua
nil
/home/wangxiao/torch/install/bin/luajit: /home/wangxiao/torch/install/share/lua/5.1/trepl/init.lua:384: /home/wangxiao/torch/install/share/lua/5.1/trepl/init.lua:384: /home/wangxiao/torch/install/share/lua/5.1/cudnn/ffi.lua:1600: 'libcudnn (R5) not found in library path.
Please install CuDNN from https://developer.nvidia.com/cuDNN
Then make sure files named as libcudnn.so.5 or libcudnn.5.dylib are placed in your library load path (for example /usr/local/lib , or manually add a path to LD_LIBRARY_PATH)

stack traceback:
[C]: in function 'error'
/home/wangxiao/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
./train_Single_Multilabel_Image_Classification.lua:8: in main chunk
[C]: in function 'dofile'
...xiao/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670
wangxiao@AHU:~/Downloads/wide-residual-networks-master$

================================================================>>

答案是:

  重新下载了 cudnn-7.5-linux-x64-v5.0-ga.tgz

  并且重新配置了,但是依然提醒这个问题,那么,问题何在呢?查看了博客:http://blog.csdn.net/hungryof/article/details/51557666 中的内容:


坑4 可能出现’libcudnn not found in library path’的情况

截取其中一段错误信息:

  1. Please install CuDNN from https://developer.nvidia.com/cuDNN
  2. Then make sure files named as libcudnn.so.5 or libcudnn.5.dylib are placed in your library load path (for example /usr/local/lib , or manually add a path to LD_LIBRARY_PATH)
  • 1
  • 2

LD_LIBRARY_PATH是该环境变量,主要用于指定查找共享库(动态链接库)时除了默认路径之外的其他路径。由于刚才已经将 
“libcudnn*”复制到了/usr/local/cuda-7.5/lib64/下面,因此需要

  1. sudo gedit /etc/ld.so.conf.d/cudnn.conf 就是新建一个conf文件。名字随便
  2. 加入刚才的路径/usr/local/cuda-7.5/lib64/
  3. 反正我还添加了/usr/local/cuda-7.5/include/,这个估计不要也行。
  4. 保存后,再sudo ldconfig来更新缓存。(可能会出现libcudnn.so.5不是符号连接的问题,不过无所谓了!!)

此时运行

  1. th neural_style.lua -gpu 0 -backend cudnn
  • 1

成功了!!!!

============================================================>>>>

评价:  按照这种做法试了,确实成功了! 赞一个 !!!


  3. 利用 gm 加载图像时,提示错误,但是装上那个包仍然提示错误:

    

  

Load library:

  1. gm = require 'graphicsmagick'

First, we provide two high-level functions to load/save directly into/form tensors:

  1. img = gm.load('/path/to/image.png' [, type]) -- type = 'float' (default) | 'double' | 'byte'
  2. gm.save('/path/to/image.jpg' [,quality]) -- quality = 0 to 100 (for jpegs only)

The following provide a more controlled flow for loading/saving jpegs.

Create an image, from a file:

  1. image = gm.Image('/path/to/image.png')
  2. -- or
  3. image = gm.Image()
  4. image:load('/path/to/image.png')
  5.  
  6.   但是悲剧的仍然有错, 只好换了用 image.load() 的方式加载图像:
      
  1. --To load as byte tensor for rgb imagefile
  2. local img = image.load(imagefile,3,'byte')
  1.  

  1.  
      4. Torch 保存 txt 文件:
      -- save opt
      file = torch.DiskFile(paths.concat(opt.checkpoints_dir, opt.name, 'opt.txt'), 'w')
      file:writeObject(opt)
      file:close()
      
      5. Torch 创建新的文件夹
      opts.modelPath = opt.modelDir .. opt.modelName
      if not paths.dirp(opt.modelPath) then
        paths.mkdir(opts.modelPath)
      end
  2.  
  3.   6. Torch Lua 保存 图像到文件夹
      借助 image package,首先安装: luarocks install image
      然后 require 'image'
      就可以使用了: local img = image.save('./saved_pos_neg_image/candidate_' .. tostring(i) .. tostring(j) .. '.png', pos_patch, 1, 32, 32)
  4.  
  5.   7. module 'bit' not found:No LuaRocks module found for bit

wangxiao@AHU:/media/wangxiao/724eaeef-e688-4b09-9cc9-dfaca44079b2/fast-neural-style-master$ th ./train.lua
/home/wangxiao/torch/install/bin/lua: /home/wangxiao/torch/install/share/lua/5.2/trepl/init.lua:389: /home/wangxiao/torch/install/share/lua/5.2/trepl/init.lua:389: /home/wangxiao/torch/install/share/lua/5.2/trepl/init.lua:389: module 'bit' not found:No LuaRocks module found for bit
no field package.preload['bit']
no file '/home/wangxiao/.luarocks/share/lua/5.2/bit.lua'
no file '/home/wangxiao/.luarocks/share/lua/5.2/bit/init.lua'
no file '/home/wangxiao/torch/install/share/lua/5.2/bit.lua'
no file '/home/wangxiao/torch/install/share/lua/5.2/bit/init.lua'
no file '/home/wangxiao/.luarocks/share/lua/5.1/bit.lua'
no file '/home/wangxiao/.luarocks/share/lua/5.1/bit/init.lua'
no file '/home/wangxiao/torch/install/share/lua/5.1/bit.lua'
no file '/home/wangxiao/torch/install/share/lua/5.1/bit/init.lua'
no file './bit.lua'
no file '/home/wangxiao/torch/install/share/luajit-2.1.0-beta1/bit.lua'
no file '/usr/local/share/lua/5.1/bit.lua'
no file '/usr/local/share/lua/5.1/bit/init.lua'
no file '/home/wangxiao/.luarocks/lib/lua/5.2/bit.so'
no file '/home/wangxiao/torch/install/lib/lua/5.2/bit.so'
no file '/home/wangxiao/torch/install/lib/bit.so'
no file '/home/wangxiao/.luarocks/lib/lua/5.1/bit.so'
no file '/home/wangxiao/torch/install/lib/lua/5.1/bit.so'
no file './bit.so'
no file '/usr/local/lib/lua/5.1/bit.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'error'
/home/wangxiao/torch/install/share/lua/5.2/trepl/init.lua:389: in function 'require'
./train.lua:5: in main chunk
[C]: in function 'dofile'
...xiao/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: in ?
wangxiao@AHU:/media/wangxiao/724eaeef-e688-4b09-9cc9-dfaca44079b2/fast-neural-style-master$

  1. 在终端中执行:luarocks install luabitop
    就可以了。

  1. 8.  HDF5Group:read() - no such child 'media' for [HDF5Group 33554432 /]

/home/wangxiao/torch/install/bin/lua: /home/wangxiao/torch/install/share/lua/5.2/hdf5/group.lua:312: HDF5Group:read() - no such child 'media' for [HDF5Group 33554432 /]
stack traceback:
[C]: in function 'error'
/home/wangxiao/torch/install/share/lua/5.2/hdf5/group.lua:312: in function </home/wangxiao/torch/install/share/lua/5.2/hdf5/group.lua:302>
(...tail calls...)
./fast_neural_style/DataLoader.lua:44: in function '__init'
/home/wangxiao/torch/install/share/lua/5.2/torch/init.lua:91: in function </home/wangxiao/torch/install/share/lua/5.2/torch/init.lua:87>
[C]: in function 'DataLoader'
./train.lua:138: in function 'main'
./train.lua:327: in main chunk
[C]: in function 'dofile'
...xiao/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: in ?

最近在训练 类型迁移的代码,发现这个蛋疼的问题。哎。。纠结好几天了。。这个 hdf5 到底怎么回事 ?  求解释 !!!

------------------------------------------------------------------------------------------------

  后来发现, 是我自己的数据集路径设置的有问题, 如: 应该是 CoCo/train/image/

  但是,我只是给定了 CoCo/train/ ...


  9. 怎么设置 torch代码在哪块 GPU 上运行 ? 或者 怎么设置在两块卡上同时运行 ?

  

    

  如图所示: export CUDA_VISIBLE_DEVICES=0 即可指定代码在 GPU-0 上运行. 

  


  10.  When load the pre-trained VGG model, got the following errors:

    MODULE data UNDEFINED
    warning: module 'data [type 5]' not found
    nn supports no groups!
    warning: module 'conv2 [type 4]' not found
    nn supports no groups!
    warning: module 'conv4 [type 4]' not found
    nn supports no groups!
    warning: module 'conv5 [type 4]' not found

  

  1. using cudnn
  2. Successfully loaded ./feature_transfer/AlexNet_files/bvlc_alexnet.caffemodel
  3. MODULE data UNDEFINED
  4. warning: module 'data [type 5]' not found
  5. nn supports no groups!
  6. warning: module 'conv2 [type 4]' not found
  7. nn supports no groups!
  8. warning: module 'conv4 [type 4]' not found
  9. nn supports no groups!
  10. warning: module 'conv5 [type 4]' not found
  1. wangxiao@AHU:~/Downloads/multi-modal-visual-tracking$ qlua ./train_match_function_alexNet_version_2017_02_28.lua
  2. using cudnn
  3. Successfully loaded ./feature_transfer/AlexNet_files/bvlc_alexnet.caffemodel
  4. MODULE data UNDEFINED
  5. warning: module 'data [type 5]' not found
  6. nn supports no groups!
  7. warning: module 'conv2 [type 4]' not found
  8. nn supports no groups!
  9. warning: module 'conv4 [type 4]' not found
  10. nn supports no groups!
  11. warning: module 'conv5 [type 4]' not found
  12. conv1:
  13. conv3:
  14. fc6:
  15. fc7:
  16. fc8:
  17. nn.Sequential {
  18. [input -> () -> () -> () -> output]
  19. (): nn.SplitTable
  20. (): nn.ParallelTable {
  21. input
  22. |`-> (): nn.Sequential {
  23. | [input -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> output]
  24. | (): nn.SpatialConvolution( -> , 11x11, ,)
  25. | (): nn.ReLU
  26. | (): nn.SpatialCrossMapLRN
  27. | (): nn.SpatialMaxPooling(3x3, ,)
  28. | (): nn.ReLU
  29. | (): nn.SpatialCrossMapLRN
  30. | (): nn.SpatialMaxPooling(3x3, ,)
  31. | (): nn.SpatialConvolution( -> , 3x3, ,, ,)
  32. | (): nn.ReLU
  33. | (): nn.ReLU
  34. | (): nn.ReLU
  35. | (): nn.SpatialMaxPooling(3x3, ,)
  36. | (): nn.View(-)
  37. | (): nn.Linear( -> )
  38. | (): nn.ReLU
  39. | (): nn.Dropout(0.500000)
  40. | (): nn.Linear( -> )
  41. | (): nn.ReLU
  42. | }
  43. `-> (): nn.Sequential {
  44. [input -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> output]
  45. (): nn.SpatialConvolution( -> , 11x11, ,)
  46. (): nn.ReLU
  47. (): nn.SpatialCrossMapLRN
  48. (): nn.SpatialMaxPooling(3x3, ,)
  49. (): nn.ReLU
  50. (): nn.SpatialCrossMapLRN
  51. (): nn.SpatialMaxPooling(3x3, ,)
  52. (): nn.SpatialConvolution( -> , 3x3, ,, ,)
  53. (): nn.ReLU
  54. (): nn.ReLU
  55. (): nn.ReLU
  56. (): nn.SpatialMaxPooling(3x3, ,)
  57. (): nn.View(-)
  58. (): nn.Linear( -> )
  59. (): nn.ReLU
  60. (): nn.Dropout(0.500000)
  61. (): nn.Linear( -> )
  62. (): nn.ReLU
  63. }
  64. ... -> output
  65. }
  66. (): nn.PairwiseDistance
  67. }
  68. =================================================================================================================
  69. ================= AlextNet based Siamese Search for Visual Tracking ========================
  70. =================================================================================================================
  71. ==>> The Benchmark Contain: videos ...
  72. deal with video / video name: BlurFace ... please waiting ...
  73. the num of gt bbox:
  74. the num of video frames:
  75. ========>>>> Begin to track video name: nil-th frame, please waiting ...
  76. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 0ms | Step: 0ms
  77. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 39s424ms | Step: 80ms
  78. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 33s746ms | Step: 69ms
  79. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 31s817ms | Step: 65ms
  80. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 32s575ms | Step: 66ms
  81. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 34s376ms | Step: 70ms
  82. ========>>>> Begin to track video name: nil-th frame, please waiting ... ............] ETA: 40s240ms | Step: 82ms
  83. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 44s211ms | Step: 91ms
  84. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 45s993ms | Step: 95ms
  85. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 47s754ms | Step: 99ms
  86. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 50s392ms | Step: 104ms
  87. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 53s138ms | Step: 110ms
  88. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 55s793ms | Step: 116ms
  89. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 59s253ms | Step: 123ms
  90. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 1m2s | Step: 130ms
  91. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 1m5s | Step: 137ms
  92. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 1m8s | Step: 143ms
  93. ========>>>> Begin to track video name: nil-th frame, please waiting ... ...........] ETA: 1m11s | Step: 149ms
  94. //////////////////////////////////////////////////////////////////////////..............] ETA: 1m14s | Step: 157ms
  95. ==>> pos_proposal_list:
  96. ==>> neg_proposal_list:
  97. qlua: /home/wangxiao/torch/install/share/lua/5.1/nn/Container.lua::
  98. In module of nn.Sequential:
  99. In module of nn.ParallelTable:
  100. In module of nn.Sequential:
  101. /home/wangxiao/torch/install/share/lua/5.1/nn/THNN.lua:: Need input of dimension and input.size[] == but got input to be of shape: [ x x ] at /tmp/luarocks_cunn-scm--/cunn/lib/THCUNN/generic/SpatialConvolutionMM.cu:
  102. stack traceback:
  103. [C]: in function 'v'
  104. /home/wangxiao/torch/install/share/lua/5.1/nn/THNN.lua:: in function 'SpatialConvolutionMM_updateOutput'
  105. ...ao/torch/install/share/lua/5.1/nn/SpatialConvolution.lua:: in function <...ao/torch/install/share/lua/5.1/nn/SpatialConvolution.lua:>
  106. [C]: in function 'xpcall'
  107. /home/wangxiao/torch/install/share/lua/5.1/nn/Container.lua:: in function 'rethrowErrors'
  108. ...e/wangxiao/torch/install/share/lua/5.1/nn/Sequential.lua:: in function <...e/wangxiao/torch/install/share/lua/5.1/nn/Sequential.lua:>
  109. [C]: in function 'xpcall'
  110. /home/wangxiao/torch/install/share/lua/5.1/nn/Container.lua:: in function 'rethrowErrors'
  111. ...angxiao/torch/install/share/lua/5.1/nn/ParallelTable.lua:: in function <...angxiao/torch/install/share/lua/5.1/nn/ParallelTable.lua:>
  112. [C]: in function 'xpcall'
  113. /home/wangxiao/torch/install/share/lua/5.1/nn/Container.lua:: in function 'rethrowErrors'
  114. ...e/wangxiao/torch/install/share/lua/5.1/nn/Sequential.lua:: in function 'forward'
  115. ./train_match_function_alexNet_version_2017_02_28.lua:: in function 'opfunc'
  116. /home/wangxiao/torch/install/share/lua/5.1/optim/adam.lua:: in function 'optim'
  117. ./train_match_function_alexNet_version_2017_02_28.lua:: in main chunk
  118.  
  119. WARNING: If you see a stack trace below, it doesn't point to the place where this error occurred. Please use only the one above.
  120. stack traceback:
  121. [C]: at 0x7f86014df9c0
  122. [C]: in function 'error'
  123. /home/wangxiao/torch/install/share/lua/5.1/nn/Container.lua:: in function 'rethrowErrors'
  124. ...e/wangxiao/torch/install/share/lua/5.1/nn/Sequential.lua:: in function 'forward'
  125. ./train_match_function_alexNet_version_2017_02_28.lua:: in function 'opfunc'
  126. /home/wangxiao/torch/install/share/lua/5.1/optim/adam.lua:: in function 'optim'
  127. ./train_match_function_alexNet_version_2017_02_28.lua:: in main chunk
  128. wangxiao@AHU:~/Downloads/multi-modal-visual-tracking$

  Just like the screen shot above, change the 'nn' into 'cudnn' will be ok and passed.

  11. both (null) and torch.FloatTensor have no less-than operator

    qlua: ./test_MM_tracker_VGG_.lua:254: both (null) and torch.FloatTensor have no less-than operator
    stack traceback:
    [C]: at 0x7f628816e9c0
    [C]: in function '__lt'
    ./test_MM_tracker_VGG_.lua:254: in main chunk

  

  Because it is floatTensor () style and you can change it like this if you want this value printed in a for loop: predictValue -->> predictValue[i] .

  

  12.

========>>>> Begin to track the 6-th and the video name is ILSVRC2015_train_00109004 , please waiting ...
THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-707/cutorch/lib/THC/generic/THCStorage.cu line=66 error=2 : out of memory
qlua: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-707/cutorch/lib/THC/generic/THCStorage.cu:66
stack traceback:
[C]: at 0x7fa20a8f99c0
[C]: at 0x7fa1dddfbee0
[C]: in function 'Tensor'
./train_match_function_VGG_version_2017_03_02.lua:377: in main chunk
wangxiao@AHU:~/Downloads/multi-modal-visual-tracking$

Yes, it is just out of memory of GPU. Just turn the batchsize to a small value, it may work. It worked for me. Ha ha ...

13. luarocks install class does not have any effect, it still shown me the error: No Module named "class" in Torch.

  ==>> in terminal, install this package in sudo.

  ==>> then, it will be OK.

14. How to install opencv 3.1 on Ubuntu 14.04 ??? 

  As we can found from: http://blog.csdn.net/a125930123/article/details/52091140

  1. first, you should install torch successfully ;

  2. then, just follow what the blog said here:

  1. 安装opencv3.1
  1. 1、安装必要的包
  1. sudo apt-get install build-essential
    sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  1. 2、下载opencv3.1
  1. http://opencv.org/downloads.html
    解压:unzip opencv-3.1.0
  1. 3、安装
    cd ~/opencv-3.1.0
    mkdir build
    cd build
    cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
  1. sudo make -j24
    sudo make install -j24  
    sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig
  1. 安装完成
  1. 4、问题
  1. 在安装过程中可能会出现无法下载 ippicv_linux_20151201.tgz的问题。
  1. 解决方案:
  1. 手动下载ippicv_linux_20151201.tgzhttps://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz
  1. 将下载好的文件 放入 opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e 中,如果已经存在 ,则替换掉,这样就可以安装完成了。
  1. 5、最后执行命令
  1. luarocks install cv

OpenCV bindings for Torch安装成功。

But, maybe you may found some errors, such as:

cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared    (solution draw from: http://blog.csdn.net/allyli0022/article/details/62859290)

At this moment, you need to change some files:

found graphcuts.cpp in opencv3.1, and do the following changes:

  1. 解决方案:需要修改一处源码:
  2. graphcuts.cpp中将
  1. #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
  1. 改为
  1. #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
  2. then, try again, it will be ok...this code just want to make opencv3.1 work under cuda 8.0, you know...skip that judge sentence...

  1. 15. 安装torch-hdf5
  1. sudo apt-get install libhdf5-serial-dev hdf5-tools
  2. git clone https://github.com/deepmind/torch-hdf5
  3. cd torch-hdf5
  4. sudo luarocks make hdf5--.rockspec LIBHDF5_LIBDIR=”/usr/lib/x86_64-Linux-gnu/”
  1.  

17. iTorch安装

  1.  
  1. git clone https://github.com/zeromq/zeromq4-1.git
  2. mkdir build-zeromq
  3. cd build-zeromq
  4. cmake ..
  5. make && make install
  6. 安装完之后,luarocks install itorch
  7. 之后可以通过luarocks list查看是否安装成功
  1.  
  1.  

Summary on deep learning framework --- Torch7的更多相关文章

  1. Summary on deep learning framework --- PyTorch

    Summary on deep learning framework --- PyTorch  Updated on 2018-07-22 21:25:42  import osos.environ[ ...

  2. Summary on deep learning framework --- Theano && Lasagne

     Summary on deep learning framework --- Theano && Lasagne 2017-03-23 1. theano.function outp ...

  3. Summary on deep learning framework --- TensorFlow

     Summary on deep learning framework --- TensorFlow Updated on 2018-07-22 21:28:11 1. Check failed: s ...

  4. Deep Learning framework --- MexNet 安装,测试,以及相关问题总结

    Deep Learning framework --- MexNet 安装,测试,以及相关问题总结  一.安装:   参考博文:http://www.open-open.com/lib/view/op ...

  5. Install and Compile MatConvNet: CNNs for MATLAB --- Deep Learning framework

    Install and Compile MatConvNet: CNNs for MATLAB --- Deep Learning framework 2017-04-18  10:19:35 If ...

  6. deep learning framework(不同的深度学习框架)

    常用的deep learning frameworks 基本转自:http://www.codeceo.com/article/10-open-source-framework.html 1. Caf ...

  7. What are some good books/papers for learning deep learning?

    What's the most effective way to get started with deep learning?       29 Answers     Yoshua Bengio, ...

  8. (转) Deep Learning Resources

    转自:http://www.jeremydjacksonphd.com/category/deep-learning/ Deep Learning Resources Posted on May 13 ...

  9. (转) Awesome Deep Learning

    Awesome Deep Learning  Table of Contents Free Online Books Courses Videos and Lectures Papers Tutori ...

随机推荐

  1. 插值代码17个---MATLAB

    函数名 功能Language 求已知数据点的拉格朗日插值多项式Atken 求已知数据点的艾特肯插值多项式Newton 求已知数据点的均差形式的牛顿插值多项式Newtonforward 求已知数据点的前 ...

  2. jps命令详解

    JPS 名称: jps - Java Virtual Machine Process Status Tool 命令用法: jps [options] [hostid] options:命令选项,用来对 ...

  3. Python selenium中注入并执行Javascript语句

    众所周知,Python通常结合selenium模块来完成一些web的自动化测试以及RPA(Robotic Process Automation)工作.事实上,Selenium还可以支持插入js语句.执 ...

  4. Windows 系统快速查看文件MD5

    关键 ·打开命令窗口(Win+R),然后输入cmd ·输入命令certutil -hashfile 文件绝对路径 MD5 快速获取文件绝对路径 ·找到文件,右键属性 注意 ·在Win7上,MD5不要使 ...

  5. datetime模块处理时间

    python常用的处理时间的库有:datetime,time,calendar.datetime库包括了date(储存日期:(年.月.日),time(储存时间:(小时.分.秒和微秒),timedelt ...

  6. vuepress 学习心得

    vuepress是一个静态网站生成器,在我看来就是写博客和教程的好工具.教程请见官网:https://www.vuepress.cn 安装方法建议局部安装:node8.0以上,新建vue项目,可能会出 ...

  7. SSH的软链接后门

    之前说过为了防止SSH的后面漏洞 , 升级到高版本的OpenSSH , 那也不能保证万无一失 经典后门  直接对sshd建立软连接 , 之后用任意密码登录即可 看下面操作 创建完软连接后  创建新的会 ...

  8. CentOS 7 Squid代理服务器正向代理-透明代理

    Squid是Linux系统中最常用的一款开源代理服务软件,主要提供缓存加速和应用层过滤控制的功能,可以很好的实现HTTP.FTP.DNS查询以及SSL等应用的缓存代理 透明代理:提供与传统代理相同的功 ...

  9. JAVA 11初体验

    JAVA 11初体验 随着JAVA没半年发布一次新版本,前几天JAVA 11隆重登场.在JAVA 11中,增加了一些新的特性和api, 同时也删除了一些特性和api,还有一些性能和垃圾回收的改进. 作 ...

  10. Java基础语法-Unicode、UTF-8、UTF-16

    1.Unicode(统一码.万国码),从名字里可以看出,unicode码表囊括世界上各国语言文字. unidode中包含17个代码级别,第一个代码级别又称作基本的多语言级别(码点从U+0000到U+F ...