Tests failure
Author: g-karthik
Pull request: no

Steps to reproduce:

1. Clone the repo.
2. Set up a plain virtual environment `venv` for the repo with Python 3.6.
3. Run `pip install .` (using the `[--editable]` didn't work and there was some error, so I just removed it)
4. Run `pip install spacy ftfy==4.4.3` and `python -m spacy download en` -- SUCCESSFUL.
5. Run `pip install pytest` -- SUCCESSFUL.
6. Run `python -m pytest -sv tests/` -- FAILURE with error below.

```
tests/modeling_gpt2_test.py::GPT2ModelTest::test_config_to_json_string PASSED
tests/modeling_gpt2_test.py::GPT2ModelTest::test_default dyld: lazy symbol binding failed: Symbol not found: _PySlice_Unpack
  Referenced from: /Users/XYZ/PycharmProjects/pytorch-pretrained-BERT/venv/lib/python3.6/site-packages/torch/lib/libtorch_python.dylib
  Expected in: flat namespace

dyld: Symbol not found: _PySlice_Unpack
  Referenced from: /Users/XYZ/PycharmProjects/pytorch-pretrained-BERT/venv/lib/python3.6/site-packages/torch/lib/libtorch_python.dylib
  Expected in: flat namespace

Abort trap: 6
```

In case it helps, these are the packages in my `venv` after I perform the first 5 steps.

```
atomicwrites | 1.3.0 | 1.3.0
attrs | 18.2.0 | 18.2.0
boto3 | 1.9.98 | 1.9.98
botocore | 1.12.98 | 1.12.98
certifi | 2018.11.29 | 2018.11.29
chardet | 3.0.4 | 3.0.4
cymem | 2.0.2 | 2.0.2
cytoolz | 0.9.0.1 | 0.9.0.1
dill | 0.2.9 | 0.2.9
docutils | 0.14 | 0.14
en-core-web-sm | 2.0.0 |  
ftfy | 4.4.3 | 5.5.1
html5lib | 1.0.1 | 1.0.1
idna | 2.8 | 2.8
jmespath | 0.9.3 | 0.9.3
more-itertools | 6.0.0 | 6.0.0
msgpack | 0.5.6 | 0.6.1
msgpack-numpy | 0.4.3.2 | 0.4.4.2
murmurhash | 1.0.2 | 1.0.2
numpy | 1.16.1 | 1.16.1
pip | 19.0.2 | 19.0.2
plac | 0.9.6 | 1.0.0
pluggy | 0.8.1 | 0.8.1
preshed | 2.0.1 | 2.0.1
py | 1.7.0 | 1.7.0
pytest | 4.3.0 | 4.3.0
python-dateutil | 2.8.0 | 2.8.0
pytorch-pretrained-bert | 0.6.1 | 0.6.1
regex | 2018.1.10 | 2019.02.20
requests | 2.21.0 | 2.21.0
s3transfer | 0.2.0 | 0.2.0
setuptools | 39.1.0 | 40.8.0
six | 1.12.0 | 1.12.0
spacy | 2.0.18 | 2.0.18
thinc | 6.12.1 | 7.0.1
toolz | 0.9.0 | 0.9.0
torch | 1.0.1.post2 | 1.0.1.post2
tqdm | 4.31.1 | 4.31.1
ujson | 1.35 | 1.35
urllib3 | 1.24.1 | 1.24.1
wcwidth | 0.1.7 | 0.1.7
webencodings | 0.5.1 | 0.5.1
wrapt | 1.10.11 | 1.11.1
```

Comments:
Update:

I manually uninstalled PyTorch (`torch | 1.0.1.post2 | 1.0.1.post2` in the list above) from my venv and installed PyTorch 0.4.0 (I couldn't find the whl file for 0.4.1 for Mac OS, which is my platform) by running

`pip install https://download.pytorch.org/whl/torch-0.4.0-cp36-cp36m-macosx_10_7_x86_64.whl`

I then ran the tests and I saw that 25 tests passed.

So I have just a couple questions at this point:
1. Given that the requirements.txt file states that the expected torch version is >= 0.4.1, and the above observation that 25 tests passed with torch 0.4.0, would all the code in this repo work with 0.4.0?

2. It is clear that the error described above occurs when using the latest version of torch, specifically torch 1.0.1.post2, but not with 0.4.0. Could you please make the necessary changes to your repo to support 1.0.1.post2?

Thanks!

Update:

Was able to find the whl for 0.4.1, so I uninstalled 0.4.0 from my venv and installed 0.4.1. Ran the tests again and 25 tests passed. So question 1 above is irrelevant now. Could I have an answer for question 2?



Hi Karthik,
On my fresh install with pytorch 1.0.1.post2 (python 3.7) all 25 tests pass without error (also on the continuous integration by the way).
Maybe try to create a clean environment? You don't have to install pytorch prior to pytorch-pretrained-bert, it's a dependency.

Hi Thomas,
I did start off with a clean virtual environment and I didn't install PyTorch prior to pytorch-pretrained-bert because I saw it's a dependency. The only difference I see between what you've described above and what I did is the version of Python: you used 3.7 while I used 3.6. Maybe that has something to do with this? Could you try with Python 3.6?

Tested on a clean python 3.6 install and all the tests pass.
Honestly there is not much more I can do at this stage.
Closing for now. Feel free to re-open if you find something.