cemoody / lda2vec

MIT License
3.15k stars 629 forks source link

Does lda2vec modelling require cuDNN and HDF5? #31

Closed radekrepo closed 8 years ago

radekrepo commented 8 years ago

Hi,

I read from the main page of this github that the only requirement for modelling is to have the CUDA support. At present, I'm trying to use code from the lda2vec_run.py file to run modelling. I have seen that there is a moment towards the end of the file where the output is saved to hdf5 but I can't find any documentation on whether CUDA + cuDNN and/or HDF5 is required to run an lda2vec model.

I ask because at present, despite installation of CUDA toolkit together with Visual Studio 2013 and setting environmental variables for Chainer, I cannot correctly import cuda to chainer.

My code is this:

import chainer from chainer import cuda from chainer import serializers import chainer.optimizers as O import numpy as np

from lda2vec import utils from lda2vec import prepare_topics, print_top_words_per_topic from lda2vec_model import LDA2Vec

gpu_id = int(os.getenv('CUDA_GPU', 0)) cuda.get_device(gpu_id).use() # tu jest w tej chwili problem print "Using GPU " + str(gpu_id)

I get an error as follows:

RuntimeError Traceback (most recent call last)

in () 20 21 gpu_id = int(os.getenv('CUDA_GPU', 0)) ---> 22 cuda.get_device(gpu_id).use() # tu jest w tej chwili problem 23 print "Using GPU " + str(gpu_id) 24 C:\Users\user\AppData\Local\Enthought\Canopy\User\lib\site-packages\chainer\cuda.pyc in get_device(*args) 159 continue 160 if not isinstance(arg, numpy.ndarray): --> 161 check_cuda_available() 162 if isinstance(arg, cupy.ndarray): 163 if arg.device is None: C:\Users\user\AppData\Local\Enthought\Canopy\User\lib\site-packages\chainer\cuda.pyc in check_cuda_available() 80 '(see https://github.com/pfnet/chainer#installation).') 81 msg += str(_resolution_error) ---> 82 raise RuntimeError(msg) 83 if not cudnn_enabled: 84 warnings.warn( RuntimeError: CUDA environment is not correctly set up (see https://github.com/pfnet/chainer#installation).cannot import name core

I would be grateful for help and any clarification.

cemoody commented 8 years ago

It doesn't require CUDA, but the code isn't written to handle that case. CPUs are just extremely slow for lda2vec, and I wouldn't recommend it. That said, a quick fix is to remove that line that calls the GPU env cuda.get_device and to remove later lines about model.to_gpu