博主在复现下面的代码时,遇到了一系列的问题,在Google在徘徊了好久才解决,先大概列出几个问题以及解决方法。
https://github.com/jzbontar/mc-cnn问题一:
运行下面代码时出错:
./main.lua kitti fast -a predict -net_fname net/net_kitti_fast_-a_train_all.t7 -left samples/input/kittiL.png -right samples/input/kittiR.png -disp_max 70
kitti fast -a predict -net_fname net/net_kitti_fast_-a_train_all.t7 -left samples/input/kittiL.png -right samples/input/kittiR.png -disp_max 70
Found Environment variable CUDNN_PATH = /usr/local/cuda/lib64/libcudnn.so.5luajit: /home/june/torch/install/share/lua/5.1/torch/File.lua:259: read error: read 0 blocks instead of 1 at /home/june/torch/pkg/torch/lib/TH/THDiskFile.c:352
stack traceback:
[C]: in function 'readInt'
/home/june/torch/install/share/lua/5.1/torch/File.lua:259: in function 'readObject'
/home/june/torch/install/share/lua/5.1/torch/File.lua:409: in function 'load'
./main.lua:898: in main chunk
[C]: at 0x00405d50
是因为现在net与运行的不符,名字与代码里面的不对应,仔细分别或重新下载后即可解决。
问题二:
运行下面代码时出错:
./main.lua kitti slow -a train_tr
luajit: ./main.lua:378: inconsistent tensor size, expected tensor [389 x 1 x 350 x 1242] and src [] to have the same number of elements, but got 169098300 and 0 elements respectively at /home/rohan140290/torch/pkg/torch/lib/TH/generic/THTensorCopy.c:86
stack traceback:
[C]: in function 'reshape'
./main.lua:378: in function 'fromfile'
./main.lua:428: in main chunk
[C]: at 0x00405d50
问题是在main.lua里面,只要改一些代码即可:(在main.lua的378行)
if type == 'float32' then
--x = torch.FloatTensor(torch.FloatStorage(fname))
s=1
for i = 1,#dim do
s = s * dim[i]
end
x = torch.FloatTensor(torch.FloatStorage(s))
torch.DiskFile(fname,'r'):binary():readFloat(x:storage())
elseif type == 'int32' then
print('inside --------------------- 1 ')
--x = torch.IntTensor(torch.IntStorage(fname))
s=1
for i = 1,#dim do
s = s * dim[i]
end
x = torch.IntTensor(torch.IntStorage(s))
torch.DiskFile(fname,'r'):binary():readInt(x:storage())
elseif type == 'int64' then
print('inside --------------------- 3 ')
--x = torch.LongTensor(torch.LongStorage(fname))
s=1
for i = 1,#dim do
s = s * dim[i]
end
x = torch.LongTensor(torch.LongStorage(s))
torch.DiskFile(fname,'r'):binary():readLong(x:storage())