如何让cUDNN在aws ubuntu GPU实例上使用lda2vec?

时间:2016-03-09 20:28:29

标签: python-2.7 amazon-web-services nlp cudnn

我一直在尝试使用lda2vec来处理GPU,如此处所述

http://nbviewer.jupyter.org/github/cemoody/lda2vec/blob/master/examples/twenty_newsgroups/lda.ipynb#topic=5&lambda=0.6&term=

我已经成功安装了CUDA,Chainer(1.6.0)和CUDNN但是当我使用GPU运行程序为True时,我得到以下内容:

  ---------------------------------------------------------------------------
CuDNNError                                Traceback (most recent call last)
<ipython-input-4-29fdc8451bd9> in <module>()
 11         model.to_gpu()
 12     model.fit(flattened, categorical_features=[doc_ids], fraction=1e-3,
---> 13               epochs=1)
 14     model.to_cpu()
 15 serializers.save_hdf5('model.hdf5', model)

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/lda2vec.pyc in fit(self, words_flat, categorical_features, targets, epochs, fraction)
436                 this_fraction = len(chunk) * 1.0 / words_flat.shape[0]
437                 self.fit_partial(chunk, this_fraction,
--> 438                                  categorical_features=cat_feats)
439 
440     def prepare_topics(self, categorical_feature_name, vocab, temperature=1.0):

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/lda2vec.pyc in fit_partial(self, words_flat, fraction, categorical_features, targets)
385         # Before calculating gradients, zero them or we will get NaN
386         self.zerograds()
--> 387         prior_loss = self._priors()
388         words_loss = self._skipgram_flat(words_flat, categorical_features)
389         trget_loss = self._target(vcategorical_features, targets)

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/lda2vec.pyc in _priors(self)
163             embedding, transform, loss_func, penalty = vals
164             name = cat_feat_name + "_mixture"
--> 165             dl = dirichlet_likelihood(self[name].weights)
166             if penalty:
167                 factors = self[name].factors.W

/usr/local/lib/python2.7/dist-packages/lda2vec-0.1-py2.7.egg/lda2vec/dirichlet_likelihood.pyc in dirichlet_likelihood(weights, alpha)
 30         proportions = F.softmax(weights)
 31     else:
---> 32         proportions = F.softmax(weights.W)
 33     loss = (alpha - 1.0) * F.log(proportions + 1e-8)
 34     return -F.sum(loss)

/usr/local/lib/python2.7/dist-packages/chainer/functions/activation/softmax.pyc in softmax(x, use_cudnn)
 90 
 91     """
---> 92     return Softmax(use_cudnn)(x)

/usr/local/lib/python2.7/dist-packages/chainer/function.pyc in __call__(self, *inputs)
103         # Forward prop
104         with cuda.get_device(*in_data):
--> 105             outputs = self.forward(in_data)
106             assert type(outputs) == tuple
107 

/usr/local/lib/python2.7/dist-packages/chainer/functions/activation/softmax.pyc in forward(self, x)
 34             one = numpy.array(1, dtype=dtype).ctypes
 35             zero = numpy.array(0, dtype=dtype).ctypes
---> 36             handle = cudnn.get_handle()
 37             x_cube = x[0].reshape(x[0].shape[:2] + (-1, 1))
 38             desc = cudnn.create_tensor_descriptor(x_cube)

/usr/local/lib/python2.7/dist-packages/cupy/cudnn.pyc in get_handle()
 16     handle = _handles.get(device.id, None)
 17     if handle is None:
---> 18         handle = cudnn.create()
 19         _handles[device.id] = handle
 20     return handle

cupy/cuda/cudnn.pyx in cupy.cuda.cudnn.create (cupy/cuda/cudnn.cpp:1567)()

cupy/cuda/cudnn.pyx in cupy.cuda.cudnn.create (cupy/cuda/cudnn.cpp:1512)()

cupy/cuda/cudnn.pyx in cupy.cuda.cudnn.check_status (cupy/cuda/cudnn.cpp:1311)()

CuDNNError: CUDNN_STATUS_NOT_INITIALIZED: CUDNN_STATUS_NOT_INITIALIZED

我已将正确的文件复制到CUDA目录并在bashrc中添加了路径。我没有先前的GPU计算问题,所以任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

不确定是否尝试让LDA2Vec正常工作,但这似乎是您在设置CUDA时遗漏了一些东西。从头开始安装CuDNN很痛苦。

截至2016年10月,AWS正在提供预装的AMI,并预装了NVIDIA CUDA 7.5。

请参阅这些博文。安装预装了CUDA的新AMI,然后再次尝试巡视代码。

AWS Blog post

AWS AMI GPU Image

NVIDIA Digits4