Hi expert,
Just cant find any solution on the web or HF. Ran into problem with following:
- from accelerate import Accelerator:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[51], line 3
1 # !pip install Transformers
2 # !pip install --upgrade accelerate
----> 3 from accelerate import Accelerator
5 # ! pip install --upgrade torchaudio torchvision
File /opt/homebrew/lib/python3.11/site-packages/accelerate/__init__.py:3
1 __version__ = "0.21.0"
----> 3 from .accelerator import Accelerator
4 from .big_modeling import (
5 cpu_offload,
6 cpu_offload_with_hook,
(...)
11 load_checkpoint_and_dispatch,
12 )
13 from .data_loader import skip_first_batches
File /opt/homebrew/lib/python3.11/site-packages/accelerate/accelerator.py:35
32 import torch
33 import torch.utils.hooks as hooks
---> 35 from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
36 from .data_loader import DataLoaderDispatcher, prepare_data_loader, skip_first_batches
37 from .logging import get_logger
File /opt/homebrew/lib/python3.11/site-packages/accelerate/checkpointing.py:24
21 import torch
22 from torch.cuda.amp import GradScaler
---> 24 from .utils import (
25 MODEL_NAME,
26 OPTIMIZER_NAME,
27 RNG_STATE_NAME,
28 SCALER_NAME,
29 SCHEDULER_NAME,
30 get_pretty_name,
31 is_tpu_available,
32 is_xpu_available,
33 save,
34 )
37 if is_tpu_available(check_device=False):
38 import torch_xla.core.xla_model as xm
File /opt/homebrew/lib/python3.11/site-packages/accelerate/utils/__init__.py:131
121 if is_deepspeed_available():
122 from .deepspeed import (
123 DeepSpeedEngineWrapper,
124 DeepSpeedOptimizerWrapper,
(...)
128 HfDeepSpeedConfig,
129 )
--> 131 from .bnb import has_4bit_bnb_layers, load_and_quantize_model
132 from .fsdp_utils import load_fsdp_model, load_fsdp_optimizer, save_fsdp_model, save_fsdp_optimizer
133 from .launch import (
134 PrepareForLaunch,
135 _filter_args,
(...)
140 prepare_tpu,
141 )
File /opt/homebrew/lib/python3.11/site-packages/accelerate/utils/bnb.py:42
31 from .modeling import (
32 find_tied_parameters,
33 get_balanced_memory,
(...)
37 set_module_tensor_to_device,
38 )
41 if is_bnb_available():
---> 42 import bitsandbytes as bnb
44 from copy import deepcopy
47 logger = logging.getLogger(__name__)
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/__init__.py:6
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
----> 6 from . import cuda_setup, utils, research
7 from .autograd._functions import (
8 MatmulLtState,
9 bmm_cublas,
(...)
13 matmul_4bit
14 )
15 from .cextension import COMPILED_WITH_CUDA
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/__init__.py:1
----> 1 from . import nn
2 from .autograd._functions import (
3 switchback_bnb,
4 matmul_fp8_global,
5 matmul_fp8_mixed,
6 )
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/nn/__init__.py:1
----> 1 from .modules import LinearFP8Mixed, LinearFP8Global
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/nn/modules.py:8
5 from torch import Tensor, device, dtype, nn
7 import bitsandbytes as bnb
----> 8 from bitsandbytes.optim import GlobalOptimManager
9 from bitsandbytes.utils import OutlierTracer, find_outlier_dims
11 T = TypeVar("T", bound="torch.nn.Module")
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/__init__.py:8
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
6 from bitsandbytes.cextension import COMPILED_WITH_CUDA
----> 8 from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit
9 from .adam import Adam, Adam8bit, Adam32bit, PagedAdam, PagedAdam8bit, PagedAdam32bit
10 from .adamw import AdamW, AdamW8bit, AdamW32bit, PagedAdamW, PagedAdamW8bit, PagedAdamW32bit
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/adagrad.py:5
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
----> 5 from bitsandbytes.optim.optimizer import Optimizer1State
8 class Adagrad(Optimizer1State):
9 def __init__(
10 self,
11 params,
(...)
21 block_wise=True,
22 ):
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/optimizer.py:12
8 from itertools import chain
10 import torch
---> 12 import bitsandbytes.functional as F
15 class MockArgs:
16 def __init__(self, initial_data):
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/functional.py:12
10 import itertools
11 import math
---> 12 from scipy.stats import norm
13 import numpy as np
15 from functools import reduce # Required in Python 3
ImportError: cannot import name 'norm' from 'scipy.stats' (unknown location)
- from transformers import RobertaForMaskedLM
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
File /opt/homebrew/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 /opt/homebrew/Cellar/python@3.11/3.11.9/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 <frozen importlib._bootstrap>:1204, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1176, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1147, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:690, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:940, in exec_module(self, module)
File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)
File /opt/homebrew/lib/python3.11/site-packages/transformers/models/roberta/modeling_roberta.py:37
27 from ...modeling_outputs import (
28 BaseModelOutputWithPastAndCrossAttentions,
29 BaseModelOutputWithPoolingAndCrossAttentions,
(...)
35 TokenClassifierOutput,
36 )
---> 37 from ...modeling_utils import PreTrainedModel
38 from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
File /opt/homebrew/lib/python3.11/site-packages/transformers/modeling_utils.py:86
85 if is_accelerate_available():
---> 86 from accelerate import dispatch_model, infer_auto_device_map, init_empty_weights
87 from accelerate.utils import (
88 check_tied_parameters_on_same_device,
89 find_tied_parameters,
(...)
94 set_module_tensor_to_device,
95 )
File /opt/homebrew/lib/python3.11/site-packages/accelerate/__init__.py:3
1 __version__ = "0.21.0"
----> 3 from .accelerator import Accelerator
4 from .big_modeling import (
5 cpu_offload,
6 cpu_offload_with_hook,
(...)
11 load_checkpoint_and_dispatch,
12 )
File /opt/homebrew/lib/python3.11/site-packages/accelerate/accelerator.py:35
33 import torch.utils.hooks as hooks
---> 35 from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
36 from .data_loader import DataLoaderDispatcher, prepare_data_loader, skip_first_batches
File /opt/homebrew/lib/python3.11/site-packages/accelerate/checkpointing.py:24
22 from torch.cuda.amp import GradScaler
---> 24 from .utils import (
25 MODEL_NAME,
26 OPTIMIZER_NAME,
27 RNG_STATE_NAME,
28 SCALER_NAME,
29 SCHEDULER_NAME,
30 get_pretty_name,
31 is_tpu_available,
32 is_xpu_available,
33 save,
34 )
37 if is_tpu_available(check_device=False):
File /opt/homebrew/lib/python3.11/site-packages/accelerate/utils/__init__.py:131
122 from .deepspeed import (
123 DeepSpeedEngineWrapper,
124 DeepSpeedOptimizerWrapper,
(...)
128 HfDeepSpeedConfig,
129 )
--> 131 from .bnb import has_4bit_bnb_layers, load_and_quantize_model
132 from .fsdp_utils import load_fsdp_model, load_fsdp_optimizer, save_fsdp_model, save_fsdp_optimizer
File /opt/homebrew/lib/python3.11/site-packages/accelerate/utils/bnb.py:42
41 if is_bnb_available():
---> 42 import bitsandbytes as bnb
44 from copy import deepcopy
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/__init__.py:6
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
----> 6 from . import cuda_setup, utils, research
7 from .autograd._functions import (
8 MatmulLtState,
9 bmm_cublas,
(...)
13 matmul_4bit
14 )
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/__init__.py:1
----> 1 from . import nn
2 from .autograd._functions import (
3 switchback_bnb,
4 matmul_fp8_global,
5 matmul_fp8_mixed,
6 )
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/nn/__init__.py:1
----> 1 from .modules import LinearFP8Mixed, LinearFP8Global
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/research/nn/modules.py:8
7 import bitsandbytes as bnb
----> 8 from bitsandbytes.optim import GlobalOptimManager
9 from bitsandbytes.utils import OutlierTracer, find_outlier_dims
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/__init__.py:8
6 from bitsandbytes.cextension import COMPILED_WITH_CUDA
----> 8 from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit
9 from .adam import Adam, Adam8bit, Adam32bit, PagedAdam, PagedAdam8bit, PagedAdam32bit
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/adagrad.py:5
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
----> 5 from bitsandbytes.optim.optimizer import Optimizer1State
8 class Adagrad(Optimizer1State):
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/optim/optimizer.py:12
10 import torch
---> 12 import bitsandbytes.functional as F
15 class MockArgs:
File /opt/homebrew/lib/python3.11/site-packages/bitsandbytes/functional.py:12
11 import math
---> 12 from scipy.stats import norm
13 import numpy as np
ImportError: cannot import name 'norm' from 'scipy.stats' (unknown location)
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In[50], line 1
----> 1 from transformers import RobertaForMaskedLM
3 # model = RobertaForMaskedLM(config=config)
4 # print(model)
File <frozen importlib._bootstrap>:1229, in _handle_fromlist(module, fromlist, import_, recursive)
File /opt/homebrew/lib/python3.11/site-packages/transformers/utils/import_utils.py:1090, in _LazyModule.__getattr__(self, name)
1088 elif name in self._class_to_module.keys():
1089 module = self._get_module(self._class_to_module[name])
-> 1090 value = getattr(module, name)
1091 else:
1092 raise AttributeError(f"module {self.__name__} has no attribute {name}")
File /opt/homebrew/lib/python3.11/site-packages/transformers/utils/import_utils.py:1089, in _LazyModule.__getattr__(self, name)
1087 value = self._get_module(name)
1088 elif name in self._class_to_module.keys():
-> 1089 module = self._get_module(self._class_to_module[name])
1090 value = getattr(module, name)
1091 else:
File /opt/homebrew/lib/python3.11/site-packages/transformers/utils/import_utils.py:1101, in _LazyModule._get_module(self, module_name)
1099 return importlib.import_module("." + module_name, self.__name__)
1100 except Exception as e:
-> 1101 raise RuntimeError(
1102 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
1103 f" traceback):\n{e}"
1104 ) from e
RuntimeError: Failed to import transformers.models.roberta.modeling_roberta because of the following error (look up to see its traceback):
cannot import name 'norm' from 'scipy.stats' (unknown location)
Have done pip --upgrade on accelerate, scipy, torch and transformers but to no success!
Any one has run into this on Mac M1? and may have a fix??
Thanks,
FXD