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

"cannot import name 'BUFSIZE' from 'numpy'" - traceback from "Sanity Check" #660

Closed
BrianSwift-Intel opened this issue Jun 18, 2024 · 5 comments
Assignees
Labels
NotAnIssue XPU/GPU XPU/GPU specific issues

Comments

@BrianSwift-Intel
Copy link

Describe the bug

After building docker image following [RECOMMENDED] Docker-based environment setup with pre-built wheels executing Sanity Check results in traceback:

(py310) ubuntu@ff3e76f79166:~$ python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__);"
/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py:266: UserWarning: Device capability of ccl unspecified, assuming `cpu` and `cuda`. Please specify it via the `devices` argument of `register_backend`.
  warnings.warn(
Warning: Cannot load xpu CCL. CCL doesn't work for XPU device
[2024-06-17 20:00:23,243] [INFO] [real_accelerator.py:191:get_accelerator] Setting ds_accelerator to cpu (auto detect)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/__init__.py", line 122, in <module>
    from . import xpu
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/xpu/__init__.py", line 20, in <module>
    from .utils import *
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/xpu/utils.py", line 6, in <module>
    from .. import frontend
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/frontend.py", line 9, in <module>
    from .nn import utils
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/__init__.py", line 1, in <module>
    from .modules import FrozenBatchNorm2d
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/modules/__init__.py", line 8, in <module>
    from ...cpu.nn.linear_fuse_eltwise import IPEXLinearEltwise
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/cpu/nn/linear_fuse_eltwise.py", line 3, in <module>
    from intel_extension_for_pytorch.nn.utils._weight_prepack import (
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/__init__.py", line 1, in <module>
    from intel_extension_for_pytorch.nn.utils import _weight_prepack
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py", line 94, in <module>
    from deepspeed import comm
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/__init__.py", line 26, in <module>
    from . import module_inject
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/module_inject/__init__.py", line 6, in <module>
    from .replace_module import replace_transformer_layer, revert_transformer_layer, ReplaceWithTensorSlicing, GroupQuantizer, generic_injection
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/module_inject/replace_module.py", line 607, in <module>
    from ..pipe import PipelineModule
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/pipe/__init__.py", line 6, in <module>
    from ..runtime.pipe import PipelineModule, LayerSpec, TiedLayerSpec
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/runtime/pipe/__init__.py", line 6, in <module>
    from .module import PipelineModule, LayerSpec, TiedLayerSpec
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/runtime/pipe/module.py", line 19, in <module>
    from ..activation_checkpointing import checkpointing
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/runtime/activation_checkpointing/checkpointing.py", line 26, in <module>
    from deepspeed.runtime.config import DeepSpeedConfig
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/runtime/config.py", line 59, in <module>
    from ..autotuning.config import DeepSpeedAutotuningConfig
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/autotuning/__init__.py", line 6, in <module>
    from .autotuner import Autotuner
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/autotuning/autotuner.py", line 20, in <module>
    from .scheduler import ResourceManager
  File "/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/deepspeed/autotuning/scheduler.py", line 8, in <module>
    from numpy import BUFSIZE
ImportError: cannot import name 'BUFSIZE' from 'numpy' (/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/numpy/__init__.py)

A docker image I built with the same process Friday (6/14/2024) works ok.

Maybe this is related to numpy version change to 2.0.0 that was just released (6/16/2024).

Versions

In the docker image that works, numpy version is 1.26.4

(py310) ubuntu@5d5fc9bfaf09:~$ python collect_env.py
/home/ubuntu/miniconda3/envs/py310/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py:266: UserWarning: Device capability of ccl unspecified, assuming `cpu` and `cuda`. Please specify it via the `devices` argument of `register_backend`.
  warnings.warn(
Warning: Cannot load xpu CCL. CCL doesn't work for XPU device
[2024-06-18 02:17:20,228] [INFO] [real_accelerator.py:191:get_accelerator] Setting ds_accelerator to cpu (auto detect)
Collecting environment information...
PyTorch version: 2.3.0+cpu
PyTorch CXX11 ABI: No
IPEX version: N/A
IPEX commit: N/A
Build type: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Clang version: N/A
IGC version: N/A
CMake version: N/A
Libc version: glibc-2.35

Python version: 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-112-generic-x86_64-with-glibc2.35
Is XPU available: N/A
DPCPP runtime version: N/A
MKL version: N/A
GPU models and configuration:
N/A
Intel OpenCL ICD version: N/A
Level Zero version: N/A

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             256
On-line CPU(s) list:                0-255
Vendor ID:                          GenuineIntel
Model name:                         INTEL(R) XEON(R) PLATINUM 8592+
CPU family:                         6
Model:                              207
Thread(s) per core:                 2
Core(s) per socket:                 64
Socket(s):                          2
Stepping:                           2
CPU max MHz:                        3900.0000
CPU min MHz:                        800.0000
BogoMIPS:                           3800.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          6 MiB (128 instances)
L1i cache:                          4 MiB (128 instances)
L2 cache:                           256 MiB (128 instances)
L3 cache:                           640 MiB (2 instances)
NUMA node(s):                       4
NUMA node0 CPU(s):                  0-31,128-159
NUMA node1 CPU(s):                  32-63,160-191
NUMA node2 CPU(s):                  64-95,192-223
NUMA node3 CPU(s):                  96-127,224-255
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] intel-extension-for-pytorch==2.3.0+cpu
[pip3] numpy==2.0.0
[pip3] torch==2.3.0+cpu
[conda] intel-extension-for-pytorch 2.3.0+cpu                pypi_0    pypi
[conda] mkl                       2023.1.0         h213fc3f_46344
[conda] numpy                     2.0.0                    pypi_0    pypi
[conda] torch                     2.3.0+cpu                pypi_0    pypi
@YuningQiu YuningQiu self-assigned this Jun 18, 2024
@vahldiek
Copy link

Yes, deepspeed tracks this as well: microsoft/DeepSpeed#5671

As a workaround, they suggest fixing the numpy version to <2.0.0. There are several ways to do this like adding another pip command at the end of the Dockerfile to install it pip install "numpy<2.0.0" or adding the numpy version to tools/env_setup.sh. This work for me for now, but seems to be a dependency one may need to carry forward at least in the short term...

@jingxu10
Copy link
Contributor

jingxu10 commented Jun 19, 2024

Yes, pls downgrade numpy to 1.26.4 as a workaround.

@BrianSwift-Intel
Copy link
Author

@YuningQiu the only problem I had building the docker image was related to need for proxy specification.
Following shows my proxy environment variables, commands used to build and run docker image, and "sanity check" command.

ppalab@emrserver:~$ env | grep -i prox
no_proxy=127.0.0.1,localhost,intel.com,.intel.com
https_proxy= Intel standard internal proxy
http_proxy= Intel standard internal proxy

time git clone https://github.com/intel/intel-extension-for-pytorch.git
cd intel-extension-for-pytorch
time git checkout v2.3.0+cpu
time git submodule sync
time git submodule update --init --recursive
date ; DOCKER_BUILDKIT=1 time docker build --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} -f examples/cpu/inference/python/llm/Dockerfile -t ipex-llm:2.3.0 . ; date

mkdir ~/bswift/containerShared
docker run -v $HOME/bswift/containerShared:/home/ubuntu/containerShared -e https_proxy=$https_proxy -e http_proxy=$http_proxy -e no_proxy=$no_proxy --rm -it --privileged ipex-llm:2.3.0 bash
cd llm
source ./tools/env_activate.sh

python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__);"

@YuningQiu
Copy link
Contributor

Thanks @BrianSwift-Intel ! For this issue, do you have other questions, or can we close this issue?

@jingxu10 jingxu10 added XPU/GPU XPU/GPU specific issues NotAnIssue labels Jul 3, 2024
@BrianSwift-Intel
Copy link
Author

Built v2.3.100 docker image per instructions at https://intel.github.io/intel-extension-for-pytorch/#installation?platform=cpu&version=v2.3.100%2bcpu&os=linux%2fwsl2&package=docker for "* Install from prebuilt wheel files" and ran "sanity check"

mkdir ipex2.3.100
cd ipex2.3.100
wget https://github.com/intel/intel-extension-for-pytorch/raw/v2.3.100+cpu/docker/Dockerfile.prebuilt
DOCKER_BUILDKIT=1 time docker build --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} -f Dockerfile.prebuilt -t ipex_prebuilt:2.3.100 .
docker run -e https_proxy=$https_proxy -e http_proxy=$http_proxy -e no_proxy=$no_proxy --rm -it --privileged ipex_prebuilt:2.3.100
python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__);"
2.3.0+cpu
2.3.100+cpu

Also did 3.3 Docker-based environment setup with compilation from source and executed some llama2 performance test.

All worked without producing "cannot import name 'BUFSIZE' from 'numpy'" - traceback
Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NotAnIssue XPU/GPU XPU/GPU specific issues
Projects
None yet
Development

No branches or pull requests

4 participants