无法导入(要求)' cutorch'在火炬

时间:2016-03-30 14:34:01

标签: lua ubuntu-14.04 torch luajit

我在我的机器上安装了CUDA 7.5,并按照here的说明安装了Torch。在安装Torch之前,我将CMake升级到版本3.2.x.x.然后我使用以下命令安装了cutorchcunn

luarocks install cutorch
luarocks install cunn

安装cutorch时,我看到一些消息说我的机器上发现了CUDA 7.5。但是,我无法使用cutorch导入require 'cotorch并在尝试使用终端中的torch(th)解释器运行它时出现以下错误:

THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-8316/cutorch/lib/THC/THCGeneral.c line=17 error=30 : unknown error
/home/amir/torch/install/share/lua/5.1/trepl/init.lua:384: cuda runtime error (30) : unknown error at /tmp/luarocks_cutorch-scm-1-8316/cutorch/lib/THC/THCGeneral.c:17
stack traceback:
    [C]: in function 'error'
    /home/amir/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
    [string "_RESULT={require "cutorch"}"]:1: in main chunk
    [C]: in function 'xpcall'
    /home/amir/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
    ...amir/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
    [C]: at 0x00406670  

然后我按照here的说明使用Eclipse来编写Lua / Torch代码。在那里,我在尝试执行require 'cutorch'时收到以下错误:

qlua: /home/amir/torch/install/share/lua/5.1/cutorch/init.lua:2: cannot load '/home/amir/torch/install/lib/lua/5.1/libcutorch.so'
stack traceback:
    [C]: at 0x7f05cf9709e0
    [C]: in function 'require'
    /home/amir/torch/install/share/lua/5.1/cutorch/init.lua:2: in main chunk
    [C]: in function 'require'
    /home/amir/workspace/test/src/main.lua:2: in function 'main'
    /home/amir/workspace/test/src/main.lua:6: in main chunk

但是,文件libcutorch.so位于上述目录中。 This也无法帮我解决问题。有谁知道我应该解决这个问题吗?

当我输入luarocks list时,我得到以下内容:

Installed rocks:
----------------

argcheck
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

cudnn
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

cunn
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

cunnx
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

cutorch
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

cwrap
   scm-1 (installed) - /home/amir/.luarocks/lib/luarocks/rocks
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

dok
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

env
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

fftw3
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

gnuplot
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

graph
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

graphicsmagick
   1.scm-0 (installed) - /home/amir/torch/install/lib/luarocks/rocks

image
   1.1.alpha-0 (installed) - /home/amir/torch/install/lib/luarocks/rocks

lbase64
   20120820-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

lua-cjson
   2.1devel-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

luaffi
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

luafilesystem
   1.6.3-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

luasocket
   3.0rc1-2 (installed) - /home/amir/torch/install/lib/luarocks/rocks

nn
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

nngraph
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

nnx
   0.1-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

optim
   1.0.5-0 (installed) - /home/amir/torch/install/lib/luarocks/rocks

paths
   scm-1 (installed) - /home/amir/.luarocks/lib/luarocks/rocks
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

penlight
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

qtlua
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

qttorch
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

signal
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

sundown
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

sys
   1.1-0 (installed) - /home/amir/torch/install/lib/luarocks/rocks

threads
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

torch
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

trepl
   scm-1 (installed) - /home/amir/torch/install/lib/luarocks/rocks

xlua
   1.0-0 (installed) - /home/amir/torch/install/lib/luarocks/rocks

2 个答案:

答案 0 :(得分:0)

好的,这就是你如何解决这个问题(感谢Torch7 google小组的alban desmaison):

  • 请确保按照我在问题中提到的所有步骤进行操作,以确保正确安装CUDA。
  • 如果您安装了Theano,请执行sudo python
  • 然后执行import theano
  • 然后转到CUDA样本文件夹和make其中一个样本(无关紧要)
  • 然后执行./[name_of_the_sample]
  • 然后Torch很容易就能使用CUDA后端

如果您没有安装Theano,请尝试使用sudo运行CUDA示例。 重要步骤是能够运行其中一个CUDA样本。

现在你已经准备好了!

答案 1 :(得分:0)

尝试sudo bash /torch/update.sh