如何让 CUDNN 在 aws ubuntu GPU 实例上与 lda2vec 一起工作?

How to get CUDNN to work with lda2vec on aws ubuntu GPU instance?

我一直在尝试使用 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 计算问题,因此非常感谢任何帮助

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

截至 2016 年 10 月,AWS 提供预装了 NVIDIA CUDA 7.5 的预构建 AMI。

请查看这些博文。获取预装了 CUDA 的新 AMI,然后再次尝试访问代码。

AWS Blog post

AWS AMI GPU Image

NVIDIA Digits4