fairseq
fairseq copied to clipboard
WeightsUnpickler error: Unsupported global: GLOBAL numpy._core.multiarray._reconstruct was not an allowed global by default.
🐛 Bug
WeightsUnpickler error: Unsupported global: GLOBAL numpy._core.multiarray._reconstruct was not an allowed global by default. Please use torch.serialization.add_safe_globals([_reconstruct]) or the torch.serialization.safe.globals([_reconstruct]) context manager to allowlist this global if you trust this class/function.
The Problem:
In fairseq, at fairseq/fairseq/checkpoint_utils.py the torch.load method is throwing error message as:
Weights only load failed. And there is 2 options to solve this:
- Make the weights_only=False
- If you to keep weights_only=True, Do Torch.serialization.add_safe_globals([argparse.Namespace])
I need weights and so used the second method, but the problem is, it throws error again telling:
RuntimeError: Can not safely load weights when explicit pickle_module is specified
I removed pickle, again it throws error saying there is those said 2 options with the new error that I shown above.
So, please help me to solve the error deadlock.
To Reproduce
I used fairseq interactive command after data preprocessing, training as shown below:
CUDA_VISIBLE_DEVICES=0 fairseq-interactive data-bin/wmt9_cs_en --path checkpoints/wmt19_cs_en/checkpoint_best.pt --beam 5 --batch-size 1 --remove-bpe sentencepiece --input sampleCS.txt
Environment
- fairseq Version (e.g., 1.0 or main):
v0.12.2 - PyTorch Version (e.g., 1.0)
2.6.0+cu126 - OS (e.g., Linux):
ubuntu 24.04 - How you installed fairseq (
pip, source):
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./
- Python version:
3.10.12 - CUDA/cuDNN version:
CUDA 12.6 - GPU models and configuration:
NVIDIA RTX A6000