Value error : Connection error
Hello,I am new in this forum and Hugging face models. Could someone help with this:I want to use model ‘Helsinki-NLP/opus-mt-en-sla’. I am using code from the site:from transformers import AutoTokenizer, AutoModelForSeq2SeqLMtokenizer = AutoTokenizer.from_pretrained(“Helsinki-NLP/opus-mt-en-sla”)model = AutoModelForSeq2SeqLM.from_pretrained(“Helsinki-NLP/opus-mt-en-sla”)but I get this error: ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.I have installed all necessary libraries and my internet connection is good…could someone help with this?Thanks
2021-02-10T14:01:40Z
Hello@Katarina, I was able to run your code snippet without any problems on my machine, so I wonder whether there is some firewall / proxy you need to configure on your end?A simple test that your connection is fine would be to spin up a Google Colab notebook and see if your code works there. Alternatively, you could try upgrading to the latest version oftransformersjust to be sure it’s not an old bug that got fixed recently.
2021-02-10T14:17:59Z
Hi Lewis, thank you on answer. I checked on Google Colab and there is working fine.I am traying from Watson Studio, so probably then I have some blockades. Do you maybe know how is possible to incorporate that part - defining a proxy into this code?
2021-02-10T14:25:21Z
Hmm I am not familiar with Watson Studio so perhaps you need to do some special login to establish a connection?If you’re running on a Linux machine, you can edit theno_proxyenvironment variable in the same shell that you’re running your code from, e.g.bash - Set a network range in the no_proxy environment variable - Unix & Linux Stack ExchangeHowever, my guess is that you might have more luck getting in touch with the IBM support to help you solve the problem
2021-02-10T14:27:17Z
Ok, I will try first with no proxy ev…thank you very much! Many regards…
2021-02-19T11:37:12Z
Hi, I just have update on this topic…I found a solution. See code below:import os#proxy= ‘http://:@:’proxy = “https://x.x.xx.x:xxxx”os.environ[‘http_proxy’] = proxyos.environ[‘HTTP_PROXY’] = proxyos.environ[‘https_proxy’] = proxyos.environ[‘HTTPS_PROXY’] = proxy
2021-07-20T21:55:47Z
I have a related question. I have an environment that doesn’t have internet. I downloaded the model inside of a docker container and moved the docker imaged into the no-internet environment.It’s still giving me the Connection Error even if I pointed to the cached_dir. Is there anyway to stop the code from requiring a internet connection and just use the cached_dir?model_name = f'Helsinki-NLP/opus-mt-mul-en'
        # Download the model and the tokenizer
        cache_dir = "/root/.cache/huggingface/transformers"
        model = MarianMTModel.from_pretrained(model_name, cache_dir=cache_dir)
        tokenizer = MarianTokenizer.from_pretrained(model_name, cache_dir=cache_dir)
2021-08-02T18:20:16Z
hey@yangliu2what happens if you set theTRANSFORMERS_OFFLINE=1as an environment variable in your docker container?see more infohere
2021-08-04T19:03:07Z
@lewtunWhat you suggested seems to work. Although this has to be set beforefrom transformers import MarianMTModel, MarianTokenizerif I want to use os package to set environmental variables.Other than it doesn’t follow PEP8, models seem to be loading okay.