mandarjoshi90 / coref

BERT for Coreference Resolution
Apache License 2.0
441 stars 92 forks source link

Issues using colab #26

Closed AradAshrafi closed 4 years ago

AradAshrafi commented 4 years ago

Is here anyone using google colab to train this model? I have faced many problems such as: 1- The model was unable to create gold_conll files in colab, I have built them in my system locally and then uploaded it to my drive to solve this. 2- I am unable to train the model, it reports a problem related to pyhocon such as follows:

Traceback (most recent call last):
  File "train.py", line 18, in <module>
    config = util.initialize_from_env()
  File "/content/coref/util.py", line 37, in initialize_from_env
    config = pyhocon.ConfigFactory.parse_file("experiments.conf")[name]
  File "/usr/local/lib/python3.6/dist-packages/pyhocon/__init__.py", line 32, in parse_file
    return ConfigFactory.parse_string(content, os.path.dirname(filename))
  File "/usr/local/lib/python3.6/dist-packages/pyhocon/__init__.py", line 60, in parse_string
    return ConfigParser().parse(content, basedir)
  File "/usr/local/lib/python3.6/dist-packages/pyhocon/__init__.py", line 198, in parse
    ConfigParser._resolve_substitutions(config, substitutions)
  File "/usr/local/lib/python3.6/dist-packages/pyhocon/__init__.py", line 241, in _resolve_substitutions
    is_optional_resolved, resolved_value = ConfigParser._resolve_variable(config, substitution)
  File "/usr/local/lib/python3.6/dist-packages/pyhocon/__init__.py", line 223, in _resolve_variable
    col=col(substitution.loc, substitution.instring)))
pyhocon.exceptions.ConfigSubstitutionException: Cannot resolve variable ${data_dir} (line: 95, col: 16)

any help with this?

mandarjoshi90 commented 4 years ago

Not sure if this is specific to colab. It looks like you haven't set the data_dir variable?

export data_dir=</path/to/data_dir>
AradAshrafi commented 4 years ago

Not sure if this is specific to colab. It looks like you haven't set the data_dir variable?

export data_dir=</path/to/data_dir>

Thanks for your reply. Yes, I include the codes to export data_dir, but it seems that Colab environment doesn't export the variable. I added a script file that includes export and python train.py, and it worked! Also, I had troubles in building .jsonlines files in setup_training process. I built these files in my system locally, then I uploaded them to my drive and used them.

Atul-Anand-Jha commented 4 years ago

Hie @AradAshrafi ,

Can you please share your code snippet of how you resolved it by including in the script itself..??

AradAshrafi commented 4 years ago

Hi @Atul-Anand-Jha I am sorry for my delay. I resolve the exporting issue by running the related commands and the export itself inside a bash script file like:

#!/bin/bash
export data_dir="conll-2012"
CUDA_VISIBLE_DEVICES=0 python3 train.py train_spanbert_base
Atul-Anand-Jha commented 4 years ago

Thanks for the reply. Btw, I also figured out a way of doing this via Python script itself; using os.envion[""] setup function.

AradAshrafi commented 4 years ago

Hi again @Atul-Anand-Jha, Have you changed the .conf file because of the recent changes in the Colab's environment? It killed the process because of the lack of GPU memory. Also, Have you tried the code on other languages?

Atul-Anand-Jha commented 4 years ago

Hi again @Atul-Anand-Jha, Have you changed the basic.conf file because of the recent changes in the Colab's environment? It killed the process because of the lack of GPU memory. Also, Have you tried the code on other languages?

No, I tried Python language only, no other languages to implement this.

And, I didn't change any configuration file as well. I did few small changes but in the main - code itself, not in the .conf.

What kind of exact bug you are getting ?

AradAshrafi commented 4 years ago

Hi again @Atul-Anand-Jha, Have you changed the basic.conf file because of the recent changes in the Colab's environment? It killed the process because of the lack of GPU memory. Also, Have you tried the code on other languages?

No, I tried Python language only, no other languages to implement this.

And, I didn't change any configuration file as well. I did few small changes but in the main - code itself, not in the .conf.

What kind of exact bug you are getting ?

Actually, It is not a bug. I get out of memory error because of the Colab's recent limitations. I was using the spanbert_base mode, and I needed to change some parameters to make this out of memory error disappear (e.g. lowering the ffnn_size). I was looking for an optimized configuration. Have you tried the model on other datasets?

mandarjoshi90 commented 4 years ago

I'm assuming this is solved and closing this. Feel free to re-open if you need to. Also leaving a link to Jonathan's Colab notebook in case someone comes across this thread later.

troublemaker-r commented 4 years ago

谢谢回复。顺便说一句,我还想出了一种通过Python脚本本身完成此操作的方法。使用os.envion[""]设置功能。

Thank you so much!