# Help Set tf=True?

**URL:** <https://discuss.pytorch.org/t/help-set-tf-true/122652>\
**Category:** Uncategorized\
**Created:** [May 28, 2021, 4:13pm UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652 "2021-05-28T16:13:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veep\_Peep](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/veep_peep/32/38825_2.png) [@Veep\_Peep](https://discuss.pytorch.org/u/Veep_Peep)\
**Post date:** [May 28, 2021, 4:13pm UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/1 "2021-05-28T16:13:46Z")

</div>

Hello,  
Not sure this is a pytorch issue .Very new to this and was trying something from a Youtube video called:

AI Text and Code Generation with GPT Neo and Python | GPT3 Clone  
[[GitHub - nicknochnack/GPTNeo](https://github.com/nicknochnack/GPTNeo)}

Using Jupyter Notebook

This line was run:

generator = pipeline(‘text-generation’, model=‘EleutherAI/gpt-neo-2.7B’) # Second line  
OSError: Unable to load weights from pytorch checkpoint file for ‘EleutherAI/gpt-neo-2.7B’ at 'C:\Users\USER7/.cache\huggingface\transformers\0839a11efa893f2a554f8f540f904b0db0e5320a2b1612eb02c3fd25471c189a.a144c17634fa6a7823e398888396dd623e204dce9e33c3175afabfbf24bd8f56’If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from\_tf=True.

I used something called Jupyter Notebook to execute each line

What I do not know, is where to set tf=True

This was the first line:  
!pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio===0.8.1 -f [https://download.pytorch.org/whl/torch\_stable.html](https://download.pytorch.org/whl/torch_stable.html)

which executed OK.

Thanks,

V

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 28, 2021, 10:55pm UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/2 "2021-05-28T22:55:16Z")

</div>

Based on the error message it seems that `Huggingface` uses the `from_tf` argument as mentioned e.g. [here](https://huggingface.co/transformers/main_classes/model.html#transformers.PreTrainedModel.from_pretrained), so you could try to pass this argument to the `from_pretrained` method, if it’s used.

---

<div class="post-metadata">

**Author:** ![Veep\_Peep](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/veep_peep/32/38825_2.png) [@Veep\_Peep](https://discuss.pytorch.org/u/Veep_Peep)\
**Post date:** [June 1, 2021, 9:06pm UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/3 "2021-06-01T21:06:39Z")

</div>

Thank you for responding.

Unfortunately this is still beyond me  
This example had 4 lines. And I guess it works for someone with the right set up - which I don’t have

not sure if I can get away with this:

generator = pipeline(‘text-generation’, model=‘EleutherAI/gpt-neo-2.7B’, from\_tf=True)

guess I will blow up my system and try again!

I really appreciate your patience!

Thank you!

---

<div class="post-metadata">

**Author:** ![Tentle](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tentle/32/41810_2.png) [@Tentle](https://discuss.pytorch.org/u/Tentle)\
**Post date:** [August 31, 2021, 4:08pm UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/4 "2021-08-31T16:08:02Z")

</div>

You’re not the only one. I also experienced this problem. Setting `from_tf` to `True` only yields

```auto
OSError: Can't load weights for 'EleutherAI/gpt-neo-2.7B'. Make sure that:

- 'EleutherAI/gpt-neo-2.7B' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'EleutherAI/gpt-neo-2.7B' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

```

---

<div class="post-metadata">

**Author:** ![Veep\_Peep](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/veep_peep/32/38825_2.png) [@Veep\_Peep](https://discuss.pytorch.org/u/Veep_Peep)\
**Post date:** [September 10, 2021, 12:30am UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/5 "2021-09-10T00:30:22Z")

</div>

Thanks for pointing this out!!!

---

<div class="post-metadata">

**Author:** ![Himanshu\_Srivastava](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/himanshu_srivastava/32/46982_2.png) [@Himanshu\_Srivastava](https://discuss.pytorch.org/u/Himanshu_Srivastava)\
**Post date:** [February 24, 2022, 10:08am UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/6 "2022-02-24T10:08:18Z")

</div>

I pre-trained the model on custom corpus from roberta-base checkpoint and saved it in drive using save\_pretrained(dir\_path).  
Now I am trying to load this pre-trained model using from\_pretrained(dir\_path) .  
I throws the same error. If anyone found the solution, please guide me in right direction.

---

<div class="post-metadata">

**Author:** ![Will\_Gerstung](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/will_gerstung/32/66093_2.png) [@Will\_Gerstung](https://discuss.pytorch.org/u/Will_Gerstung)\
**Post date:** [December 8, 2023, 3:25am UTC](https://discuss.pytorch.org/t/help-set-tf-true/122652/7 "2023-12-08T03:25:00Z")

</div>

pip install accelerate
