question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing transformers causes segmentation fault when setting cuda device

See original GitHub issue

🐛 Bug

Information

The problem arises when using: my own modified scripts: (give details below)

To reproduce

import torch
import transformers

def main(local_rank):
    torch.cuda.set_device(local_rank)
    device = torch.device('cuda', local_rank)

if __name__ == "__main__":
    print (torch.__version__)
    print (transformers.__version__)
    print (torch.cuda.is_available())
    main(0)

Expected behavior

1.4.0
2.11.0
True
Segmentation fault (core dumped)

if commenting out import transformers, everything will be fine.

Environment info

  • transformers version: 2.11.0
  • Platform: linux
  • Python version: 3.6.8
  • PyTorch version (GPU?): 1.4.0 GPU
  • Tensorflow version (GPU?): None
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
huangxiaoshuocommented, Jun 29, 2020

@daphnei thx for pointing out this! The solution for me was to upgrade torch to 1.5.1+cu92, and downgrade transformers version to 2.6.0. Quite weird problem!

I have met the exactly same problem with you, and did you find the root cause? is this issue same to report ‘fix segmentation fault’ #2207? The following were my test results with different versions:

  1. Segmentation fault (core dumped): torch 1.2.0 ; transformers 2.11.0;cuda 10.0
  2. Segmentation fault (core dumped): torch 1.2.0 ; transformers 2.6.0;cuda 10.0
  3. Segmentation fault (core dumped): torch 1.2.0 ; transformers 2.5.1;cuda 10.0
  4. Success: torch 1.1.0 ; transformers 2.5.1;cuda 10.0

BTW, is there a torch release of ‘1.5.1+cuda10.0’? Thanks.

4reactions
daphneicommented, Jun 19, 2020

EDIT: This problem is caused by the sentencepiece dependency. It goes away if I comment out all references to this dependency. This will break xlnet, xlm_roberta, marian, t5, albert, reformer, and camembert, but if you are using any of the non-sentencepiece models, this should solve your problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Segmentation fault error in importing sentence_transformers ...
I fixed the issue by changing the pytorch version from 1.4.0 to 1.6.0. So the requirements.txt looks like this:
Read more >
Troubleshoot - Hugging Face
Troubleshoot. Sometimes errors occur, but we are here to help! This guide covers some of the most common issues we've seen and how...
Read more >
Core dumped when training, no error messages
Thread 32 "python" received signal SIGSEGV, Segmentation fault. ... Reproduction of an issue causing a core dump on Pytorch (1.8.1+cu111) ...
Read more >
trax-ml/community - Gitter
import trax Segmentation fault (core dumped) root@f414b9a83bb9:/# python3 ... is retained if set previously) ARG ARCH ARG CUDA ARG CUDNN=7.6.5.32-1 ARG ...
Read more >
NVIDIA Deep Learning TensorRT Documentation
NVIDIA ® TensorRT™ is an SDK that facilitates high-performance machine learning ... TensorRT ships with an ONNX parser library to assist in importing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found