Closed raj-ritu17 closed 1 month ago
Hi @raj-ritu17 , this is not a ipex issue and as you said it is related to setuptools package version installed by miniforge3.
and yes you can downgrade your setuptools by python -m pip install setuptools==69.5.1
to fix it.
This also happens in a freshly installed Conda when creating a new environment from scratch, specifically
conda create --name ipex3 python=3.10 intel-extension-for-pytorch=2.1.30 pytorch=2.1.0 -c intel -c conda-forge
yields an environment where importing ipex fails with the ImportError: cannot import name 'packaging' from 'pkg_resources'
error.
Workaround: running conda install 'setuptools<70.0.0'
in the environment to downgrades setuptools to a compatible version and IPEX works again.
Fix: consider adding a "<" version dependency for setuptools
, perhaps here for pip users. Conda package does not seem to list a dependency on setuptools (based on looking at "depends" in miniconda3/pkgs/intel-extension-for-pytorch-2.1.30-py310_xpu_0/info/index.json
after installing the package) so it may need to be added there as well. (note that I don't have much experience with publishing packages so there might be a better place to specify dependencies)
Alternatively, when IPEX gets upgraded to PyTorch > 2.1.x, this might be automatically resolved since the offending import was removed in PyTorch v2.2.0.
Hi @martinmCGG , thanks for advice, we add pip install setuptools==69.5.1 in our installation document. https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu&version=v2.1.30%2bxpu&os=linux%2fwsl2&package=pip
Hi @raj-ritu17 , this is not a ipex issue and as you said it is related to setuptools package version installed by miniforge3. and yes you can downgrade your setuptools by
python -m pip install setuptools==69.5.1
to fix it.
It seems like this is not a bug in setuptools but a breaking change: https://github.com/pypa/setuptools/issues/4385#issuecomment-2126286321
Couldnt just importing packaging
directly fix it for newer setuptools while still being compatible with older setuptools ?
Describe the bug
created a conda env with python 3.11, have setup with all required library. ran sanity test, it fails to import pkg_resources:
python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"
error:
resolution: it comes from the setup tools, downgrade the tools:
python -m pip install setuptools==69.5.1
output after downgrading:
Versions