NameError: name 'LRScheduler' is not defined"
#467
by
zh-zhang1984
- opened
when I import below package, it report errors, what is the possible solution for this?
# imports
from collections import Counter
import datetime
import pickle
import subprocess
import seaborn as sns; sns.set()
from datasets import load_from_disk
from sklearn.metrics import accuracy_score, f1_score
from transformers import BertForSequenceClassification
from transformers import Trainer
from transformers.training_args import TrainingArguments
from geneformer import DataCollatorForCellClassification
{
"name": "NameError",
"message": "name 'LRScheduler' is not defined",
"stack": "---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[10], line 13
10 from transformers import Trainer
11 from transformers.training_args import TrainingArguments
---> 13 from geneformer import DataCollatorForCellClassification
File /opt/miniconda3/envs/geneformer/lib/python3.12/site-packages/geneformer/__init__.py:2
1 from . import tokenizer
----> 2 from . import pretrainer
3 from . import collator_for_classification
4 from . import in_silico_perturber
File /opt/miniconda3/envs/geneformer/lib/python3.12/site-packages/geneformer/pretrainer.py:26
19 from transformers import (
20 BatchEncoding,
21 DataCollatorForLanguageModeling,
22 SpecialTokensMixin,
23 Trainer,
24 )
25 from transformers.file_utils import is_datasets_available, is_sagemaker_dp_enabled
---> 26 from transformers.trainer_pt_utils import (
27 DistributedLengthGroupedSampler,
28 DistributedSamplerWithLoop,
29 LengthGroupedSampler,
30 )
31 from transformers.training_args import ParallelMode
32 from transformers.utils import is_tf_available, is_torch_available, logging, to_py_obj
File /opt/miniconda3/envs/geneformer/lib/python3.12/site-packages/transformers/trainer_pt_utils.py:1368
1364 def step(self, closure=None) -> Optional[float]:
1365 pass
-> 1368 class LayerWiseDummyScheduler(LRScheduler):
1369 \"\"\"
1370 For Layer-wise optimizers such as GaLoRE optimizer, the optimization and scheduling step
1371 are already done through the post gradient hooks. Therefore
1372 the trick is to create a dummy scheduler that can take arbitrary
1373 args and kwargs and return a no-op during training.
1374 \"\"\"
1376 def __init__(self, *args, **kwargs):
NameError: name 'LRScheduler' is not defined"
}
The package versions are as follows:
# packages in environment at /opt/miniconda3/envs/geneformer:
#
# Name Version Build Channel
accumulation-tree 0.6.4 pypi_0 pypi
aiohappyeyeballs 2.4.4 pypi_0 pypi
aiohttp 3.11.11 pypi_0 pypi
aiosignal 1.3.2 pypi_0 pypi
anndata 0.11.1 pyhd8ed1ab_1 conda-forge
appnope 0.1.4 pyhd8ed1ab_1 conda-forge
array-api-compat 1.10.0 pyhd8ed1ab_0 conda-forge
asttokens 3.0.0 pyhd8ed1ab_1 conda-forge
attrs 24.3.0 pypi_0 pypi
blas 1.0 openblas
bottleneck 1.4.2 py312ha86b861_0
brotli 1.0.9 h80987f9_8
brotli-bin 1.0.9 h80987f9_8
bzip2 1.0.8 h80987f9_6
c-ares 1.34.4 h5505292_0 conda-forge
ca-certificates 2024.12.14 hf0a4a13_0 conda-forge
certifi 2024.12.14 pypi_0 pypi
cffi 1.17.1 py312h3eb5a62_0
charset-normalizer 3.4.1 pypi_0 pypi
click 8.1.8 pypi_0 pypi
comm 0.2.2 pyhd8ed1ab_1 conda-forge
contourpy 1.3.1 py312h48ca7d4_0
cycler 0.11.0 pyhd3eb1b0_0
datasets 3.2.0 pypi_0 pypi
debugpy 1.6.7 py312h313beb8_0
decorator 5.1.1 pyhd8ed1ab_1 conda-forge
dill 0.3.8 pypi_0 pypi
exceptiongroup 1.2.2 pyhd8ed1ab_1 conda-forge
executing 2.1.0 pyhd8ed1ab_1 conda-forge
expat 2.6.4 h313beb8_0
filelock 3.16.1 pypi_0 pypi
fonttools 4.51.0 py312h80987f9_0
freetype 2.12.1 h1192e45_0
frozenlist 1.5.0 pypi_0 pypi
fsspec 2024.9.0 pypi_0 pypi
geneformer 0.0.1 pypi_0 pypi
h5py 3.12.1 py312h8456320_0
hdf5 1.12.1 h05c076b_3
huggingface-hub 0.27.0 pypi_0 pypi
idna 3.10 pypi_0 pypi
importlib-metadata 8.5.0 pyha770c72_1 conda-forge
ipykernel 6.29.5 pyh57ce528_0 conda-forge
ipython 8.31.0 pyh707e725_0 conda-forge
jedi 0.19.2 pyhd8ed1ab_1 conda-forge
jinja2 3.1.4 py312hca03da5_1
joblib 1.4.2 py312hca03da5_0
jpeg 9e h80987f9_3
jupyter_client 8.6.3 pyhd8ed1ab_1 conda-forge
jupyter_core 5.7.2 pyh31011fe_1 conda-forge
kiwisolver 1.4.4 py312h313beb8_0
krb5 1.20.1 h69eda48_0 conda-forge
lcms2 2.16 he93ba84_0
lerc 4.0.0 h313beb8_0
libabseil 20240116.2 cxx17_h313beb8_0
libbrotlicommon 1.0.9 h80987f9_8
libbrotlidec 1.0.9 h80987f9_8
libbrotlienc 1.0.9 h80987f9_8
libcurl 8.11.1 hde089ae_0
libcxx 14.0.6 h848a8c0_0
libdeflate 1.22 h80987f9_0
libedit 3.1.20191231 hc8eb9b7_2 conda-forge
libev 4.33 h93a5062_2 conda-forge
libffi 3.4.4 hca03da5_1
libgfortran 5.0.0 11_3_0_hca03da5_28
libgfortran5 11.3.0 h009349e_28
libnghttp2 1.57.0 h62f6fdd_0
libopenblas 0.3.21 h269037a_0
libpng 1.6.39 h80987f9_0
libprotobuf 3.20.3 h514c7bf_0
libsodium 1.0.18 h27ca646_1 conda-forge
libssh2 1.11.1 h3e2b118_0
libtiff 4.5.1 hc9ead59_1
libuv 1.48.0 h80987f9_0
libwebp-base 1.3.2 h80987f9_1
llvm-openmp 14.0.6 hc6e5704_0
llvmlite 0.43.0 pypi_0 pypi
loompy 3.0.7 pypi_0 pypi
lz4-c 1.9.4 h313beb8_1
markupsafe 2.1.3 py312h80987f9_0
matplotlib-base 3.9.2 py312h7ef442a_1
matplotlib-inline 0.1.7 pyhd8ed1ab_1 conda-forge
mpmath 1.3.0 py312hca03da5_0
multidict 6.1.0 pypi_0 pypi
multiprocess 0.70.16 pypi_0 pypi
natsort 8.4.0 pyh29332c3_1 conda-forge
ncurses 6.4 h313beb8_0
nest-asyncio 1.6.0 pyhd8ed1ab_1 conda-forge
networkx 3.3 py312hca03da5_0
ninja 1.12.1 hca03da5_0
ninja-base 1.12.1 h48ca7d4_0
numba 0.60.0 pypi_0 pypi
numexpr 2.10.1 py312h5d9532f_0
numpy 2.0.2 pypi_0 pypi
numpy-base 1.26.4 py312he047099_0
numpy-groupies 0.11.2 pypi_0 pypi
openjpeg 2.5.2 h54b8e55_0
openssl 3.4.0 h39f12f2_0 conda-forge
packaging 24.2 pyhd8ed1ab_2 conda-forge
pandas 2.2.3 py312hcf29cfe_0
parso 0.8.4 pyhd8ed1ab_1 conda-forge
pexpect 4.9.0 pyhd8ed1ab_1 conda-forge
pickleshare 0.7.5 pyhd8ed1ab_1004 conda-forge
pillow 11.0.0 py312h84e58ab_1
pip 24.2 py312hca03da5_0
platformdirs 4.3.6 pyhd8ed1ab_1 conda-forge
prompt-toolkit 3.0.48 pyha770c72_1 conda-forge
propcache 0.2.1 pypi_0 pypi
psutil 5.9.0 py312h80987f9_0
ptyprocess 0.7.0 pyhd8ed1ab_1 conda-forge
pure_eval 0.2.3 pyhd8ed1ab_1 conda-forge
pyarrow 18.1.0 pypi_0 pypi
pycparser 2.21 pyhd3eb1b0_0
pygments 2.18.0 pyhd8ed1ab_1 conda-forge
pyparsing 3.2.0 py312hca03da5_0
python 3.12.8 h99e199e_0
python-dateutil 2.9.0.post0 pyhff2d567_1 conda-forge
python-tzdata 2023.3 pyhd3eb1b0_0
pytorch 2.2.0 gpu_mps_py312h0502254_100
pytz 2024.2 pypi_0 pypi
pyudorandom 1.0.0 pypi_0 pypi
pyyaml 6.0.2 pypi_0 pypi
pyzmq 26.2.0 py312h313beb8_0
readline 8.2 h1a28f6b_0
regex 2024.11.6 pypi_0 pypi
requests 2.32.3 pypi_0 pypi
safetensors 0.5.0 pypi_0 pypi
scikit-learn 1.5.2 py312h313beb8_0
scipy 1.14.1 py312ha409365_0
seaborn 0.13.2 py312hca03da5_0
setuptools 75.1.0 py312hca03da5_0
six 1.17.0 pyhd8ed1ab_0 conda-forge
sleef 3.5.1 h80987f9_2
sqlite 3.45.3 h80987f9_0
stack_data 0.6.3 pyhd8ed1ab_1 conda-forge
sympy 1.13.3 py312hca03da5_0
tdigest 0.5.2.2 pypi_0 pypi
threadpoolctl 3.5.0 py312h989b03a_0
tk 8.6.14 h6ba3021_0
tokenizers 0.21.0 pypi_0 pypi
tornado 6.4.2 py312h80987f9_0
tqdm 4.67.1 pypi_0 pypi
traitlets 5.14.3 pyhd8ed1ab_1 conda-forge
transformers 4.47.1 pypi_0 pypi
typing_extensions 4.12.2 pyha770c72_1 conda-forge
tzdata 2024.2 pypi_0 pypi
unicodedata2 15.1.0 py312h80987f9_0
urllib3 2.3.0 pypi_0 pypi
wcwidth 0.2.13 pyhd8ed1ab_1 conda-forge
wheel 0.44.0 py312hca03da5_0
xxhash 3.5.0 pypi_0 pypi
xz 5.4.6 h80987f9_1
yarl 1.18.3 pypi_0 pypi
zeromq 4.3.5 h313beb8_0
zipp 3.21.0 pyhd8ed1ab_1 conda-forge
zlib 1.2.13 h18a0788_1
zstd 1.5.6 hfb09047_0