allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.76k stars 2.25k forks source link

__jsonnet not loaded and other warnings #4056

Closed alikabeer32 closed 4 years ago

alikabeer32 commented 4 years ago

My code:

import sys 

from allennlp.predictors.predictor import Predictor

predictor = Predictor.from_path(
    "https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2018.11.30-charpad.tar.gz"
  )

prediction = predictor.predict(
    passage="Tokyo in Japan. With more than 38 million inhabitants Tokyo is the largest city and has the largest metropolitan area. This city has more inhabitants than the whole country of Canada!", 
    question="How many people live in Tokyo?"
  )
print(prediction["best_span_str"])

Output:

_jsonnet not loaded, treating C:\Users\Ali\AppData\Local\Temp\tmpyq9fyr59\config.json as json
_jsonnet not loaded, treating snippet as json
D:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:51: UserWarning: dropout option adds dropout after all but last recurrent layer, so non-zero dropout expects num_layers greater than 1, but got dropout=0.2 and num_layers=1
  "num_layers={}".format(dropout, num_layers))
D:\anaconda3\lib\site-packages\allennlp\data\token_indexers\token_characters_indexer.py:56: UserWarning: You are using the default value (0) of `min_padding_length`, which can cause some subtle bugs (more info see https://github.com/allenai/allennlp/issues/1954). Strongly recommend to set a value, usually the maximum size of the convolutional layer size when using CnnEncoder.
  UserWarning)
38 million

As you can see I am getting the desired answer but it's SUPER slow compared to the demo on the allennlp site. I figure it has something to do with the warnings?

My OS: Windows 10 Python: 3.7.6

PS: I can't seem to be able to install jsonnet at all. Is it even available for windows?

alikabeer32 commented 4 years ago

This is when I try to install jsonnet

pip install jsonnet
Collecting jsonnet
  Using cached jsonnet-0.15.0.tar.gz (255 kB)
Building wheels for collected packages: jsonnet
  Building wheel for jsonnet (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Ali\AppData\Local\Temp\pip-wheel-qhp24t5g'
       cwd: C:\Users\Ali\AppData\Local\Temp\pip-install-rdxd8xcw\jsonnet\
  Complete output (4 lines):
  running bdist_wheel
  running build
  running build_ext
  error: [WinError 2] The system cannot find the file specified
  ----------------------------------------
  ERROR: Failed building wheel for jsonnet
  Running setup.py clean for jsonnet
Failed to build jsonnet
Installing collected packages: jsonnet
    Running setup.py install for jsonnet ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Ali\AppData\Local\Temp\pip-record-rlns9qaa\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\anaconda3\Include\jsonnet'
         cwd: C:\Users\Ali\AppData\Local\Temp\pip-install-rdxd8xcw\jsonnet\
    Complete output (4 lines):
    running install
    running build
    running build_ext
    error: [WinError 2] The system cannot find the file specified
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ali\\AppData\\Local\\Temp\\pip-install-rdxd8xcw\\jsonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Ali\AppData\Local\Temp\pip-record-rlns9qaa\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\anaconda3\Include\jsonnet' Check the logs for full command output.
schmmd commented 4 years ago

@alikabeer32 we don't officially support windows. Jsonnet has been a sticking point for windows users: https://github.com/allenai/allennlp/issues/612

We'd welcome contributions but are unlikely to prioritize this ourselves.

MausamGaurav commented 3 years ago

Is there a workaround ?

rkrishna116 commented 2 years ago

@MausamGaurav, @alikabeer32, for now you can pip install jsonnetbin to avoid this warning/error.