NVIDIA / sentiment-discovery

Unsupervised Language Modeling at scale for robust sentiment classification
Other
1.06k stars 202 forks source link

Running sentiment-discovery? #13

Open yashkumaratri opened 6 years ago

yashkumaratri commented 6 years ago

I tried following the docs for installing and running the program.

At first I tried

 pip setup.py install
ERROR: unknown command "setup.py"

Next I tried

 python setup.py install

Arguments used to build CUDA extension:
extra_compile_args : ['--std=c++11']
include_dirs:  ['/home/friday/anaconda3/lib/python3.6/site-packages/torch/lib/include', '/home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/include', '/usr/local/cuda/include']
extra_link_args:  []
library_dirs:  ['/home/friday/anaconda3/lib/python3.6/site-packages/torch/lib', '/usr/local/cuda/lib64']
libraries:  ['cudart', 'cuda', 'ATen']

Compiling cuda modules with nvcc:
nvcc -Xcompiler -fPIC -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70 --std=c++11 -O3 -I/home/friday/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/include -I/usr/local/cuda/include -c /home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/csrc/kernel.cu -o /home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/build/kernel.o
nvcc fatal   : Unsupported gpu architecture 'compute_60'
Traceback (most recent call last):
  File "setup.py", line 159, in <module>
    CompileCudaFiles()
  File "setup.py", line 146, in CompileCudaFiles
    subprocess.check_call(nvcc_cmd+file_opts)
  File "/home/friday/anaconda3/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['nvcc', '-Xcompiler', '-fPIC', '-gencode', 'arch=compute_52,code=sm_52', '-gencode', 'arch=compute_60,code=sm_60', '-gencode', 'arch=compute_61,code=sm_61', '-gencode', 'arch=compute_70,code=sm_70', '-gencode', 'arch=compute_70,code=compute_70', '--std=c++11', '-O3', '-I/home/friday/anaconda3/lib/python3.6/site-packages/torch/lib/include', '-I/home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/include', '-I/usr/local/cuda/include', '-c', '/home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/csrc/kernel.cu', '-o', '/home/friday/Documents/Sentiment Analysis/sentiment-discoverylatest/apex_utils/build/kernel.o']' returned non-zero exit status 1.

Later just to run the sentiment classifier i ran

 python3 transfer.py --load_model sst_clf.pt --neurons 5
Traceback (most recent call last):
  File "transfer.py", line 20, in <module>
    from apex.reparameterization import apply_weight_norm, remove_weight_norm
  File "/home/friday/anaconda3/lib/python3.6/site-packages/apex/__init__.py", line 18, in <module>
    from apex.interfaces import (ApexImplementation,
  File "/home/friday/anaconda3/lib/python3.6/site-packages/apex/interfaces.py", line 10, in <module>
    class ApexImplementation(object):
  File "/home/friday/anaconda3/lib/python3.6/site-packages/apex/interfaces.py", line 14, in ApexImplementation
    implements(IApex)
  File "/home/friday/anaconda3/lib/python3.6/site-packages/zope/interface/declarations.py", line 404, in implements
    raise TypeError(_ADVICE_ERROR % 'implementer')
TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.

So I tried changing the zope.interface versions and apex versions but it still throws error.

Tried to run with native python3 as well as conda3 but it doesn't work.

So anyone can give me an advice or just give me a version controlled list of requirements.txt, It'll be so helpful, Please guys :)

raulpuric commented 6 years ago

Hmmm several questions. What version of cuda do you have installed if any? Do you have the latest version of PyTorch installed?

yashkumaratri commented 6 years ago

I have cuda 8 installed I installed torch from http://pytorch.org/

and it installs torch-0.3.1 , but the repo docs says to install PyTorch 0.4.0 PyTorch says to run these 2 commands in terminal

pip3 install http://download.pytorch.org/whl/cu80/torch-0.3.1-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision

As of now I've resetted my system and installed python 3.6.3, So should I install every packages latest version.

or you can tell me what version of what should I install, I just want to run the sentiment classifier only (just want to test the result over some sentences)

raulpuric commented 6 years ago

Hi, pytorch only has pre-built wheels for 0.3 currently. In order to get pytorch 0.4 you have to build from top of tree. Try following the instructions here to build pytorch 0.4 from source.

it also seems like you pip installed apex from pypi. Our version of apex (A PyTorch Extension) has a name conflict with an already existing apex package in pypi. While we work to resolve this please uninstall the current version of apex you have with pip uninstall -y apex, and install our version with python ./setup.py install.

Let me know if that works. Thanks for your patience.

raulpuric commented 6 years ago

Turns out cuda8.0 doesn't build properly. While we address this please try building from our latest commit. 046d09a5c3b186536bc8c0f33ad7abec00a8af1d

yashkumaratri commented 6 years ago

The code is running flawless , thanks for helping me out.

raulpuric commented 6 years ago

keeping this open until we get it working for both 8 and 9

yashkumaratri commented 6 years ago

Tried the new model (sst_8k.pt) and it is throwing errors

python3 generate.py --load_model sst_8k.pt --gen_length -1 --visualize --text "Happy testing" Creating mlstm Traceback (most recent call last): File "generate.py", line 212, in neuron, polarity = get_neuron_and_polarity(sd, args.neuron) File "generate.py", line 106, in get_neuron_and_polarity val, neuron = torch.max(torch.abs(weight[0]), 0) RuntimeError: abs is not implemented for type torch.HalfTensor

raulpuric commented 6 years ago

try 199c273c15e7d545c08c74ef20a7c0644fad9822 Added a simple conversion converting weight[0] to float. Didn't test all the way through though

yashkumaratri commented 6 years ago

Sorry for the late reply but the code still throws error

python3 generatenew.py --load_model sst_8k.pt --gen_length -1 --visualize --text "25 August 2003 League of Extraordinary Gentlemen: Sean Connery is one of 
the all time greats I have been a fan of his since the 1950's."
Creating mlstm
generatenew.py:107: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  neuron = neuron[0]
Traceback (most recent call last):
  File "generatenew.py", line 202, in <module>
    neuron, polarity = get_neuron_and_polarity(sd, args.neuron)
  File "generatenew.py", line 108, in get_neuron_and_polarity
    val = weight[0][neuron]
RuntimeError: take is not implemented for type torch.HalfTensor
yashkumaratri commented 6 years ago

line 108 : val = weight[0].float()[neuron] Solved it