Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback): cannot import name 'gather_traceback' from 'torch._C._profiler' (unknown location) #1490

Open
AntNeo opened this issue Mar 28, 2024 · 0 comments

Comments

@AntNeo
Copy link

AntNeo commented Mar 28, 2024

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

from wordcloud import WordCloud
import re
import unicodedata
import nltk
import csv
import string
!pip3 install textblob
from textblob import TextBlob
from nltk.corpus import stopwords
!pip3 install demoji
nltk.download('all')
import demoji
!pip3 install -q transformers

!pip3 install torch --upgrade
!pip3 install torchtext==0.6.0

import pickle
import torch
import torch.nn as nn
import torch.nn.functional as F
SEED = 1024
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.backends.cudnn.deterministic = True

from torch.utils.data import TensorDataset, DataLoader, Dataset, RandomSampler, SequentialSampler
import torchtext
from torchtext import data

import transformers
from transformers import BertTokenizer, BertModel, BertConfig

import warnings
warnings.filterwarnings('ignore')
import operator

from sklearn.metrics import hamming_loss, jaccard_score, label_ranking_average_precision_score, f1_score
from tqdm._tqdm_notebook import tqdm_notebook as tqdm

ImportError Traceback (most recent call last)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/utils/import_utils.py:1099, in _LazyModule._get_module(self, module_name)
1098 try:
-> 1099 return importlib.import_module("." + module_name, self.name)
1100 except Exception as e:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1204, in _gcd_import(name, package, level)

File :1176, in find_and_load(name, import)

File :1147, in find_and_load_unlocked(name, import)

File :690, in _load_unlocked(spec)

File :940, in exec_module(self, module)

File :241, in _call_with_frames_removed(f, *args, **kwds)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py:26
25 import torch
...
1103 f" traceback):\n{e}"
1104 ) from e

RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback):
cannot import name 'gather_traceback' from 'torch._C._profiler' (unknown location)

Someone please help me

Tasks

No tasks being tracked yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant