ERROR: Could not build wheels for apex, which is required to install pyproject.toml-based projects
my environment
- Python: 3.7.12
- Pytorch: 1.8.1
my issue
I used the following command to install apex, but encountered an error.
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
ERROR INFO
Using pip 23.1.2 from /data/songyinghao/.conda/envs/dali_apex/lib/python3.7/site-packages/pip (python 3.7)
DEPRECATION: --build-option and --global-option are deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use --config-settings. Discussion can be found at https://github.com/pypa/pip/issues/11859
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option.
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/, https://pypi.ngc.nvidia.com
Processing /data/songyinghao/apex-master
Running command python setup.py egg_info
torch.__version__ = 1.8.1+cu101
running egg_info
creating /tmp/pip-pip-egg-info-o23ysjua/apex.egg-info
writing /tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/dependency_links.txt
writing requirements to /tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/requires.txt
writing top-level names to /tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file '/tmp/pip-pip-egg-info-o23ysjua/apex.egg-info/SOURCES.txt'
Preparing metadata (setup.py) ... done
Requirement already satisfied: packaging>20.6 in /data/songyinghao/.conda/envs/dali_apex/lib/python3.7/site-packages (from apex==0.1) (23.1)
Building wheels for collected packages: apex
Running command python setup.py bdist_wheel
torch.__version__ = 1.8.1+cu101
Compiling cuda extensions with
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
from /usr/bin
running bdist_wheel
/data/songyinghao/.conda/envs/dali_apex/lib/python3.7/site-packages/torch/utils/cpp_extension.py:369: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
running build
running build_py
creating build/lib.linux-x86_64-cpython-37
creating build/lib.linux-x86_64-cpython-37/apex
copying apex/__init__.py -> build/lib.linux-x86_64-cpython-37/apex
creating build/lib.linux-x86_64-cpython-37/apex/multi_tensor_apply
copying apex/multi_tensor_apply/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/multi_tensor_apply
creating build/lib.linux-x86_64-cpython-37/apex/parallel
copying apex/parallel/optimized_sync_batchnorm.py -> build/lib.linux-x86_64-cpython-37/apex/parallel
copying apex/parallel/sync_batchnorm.py -> build/lib.linux-x86_64-cpython-37/apex/parallel
copying apex/parallel/LARC.py -> build/lib.linux-x86_64-cpython-37/apex/parallel
copying apex/parallel/sync_batchnorm_kernel.py -> build/lib.linux-x86_64-cpython-37/apex/parallel
copying apex/parallel/distributed.py -> build/lib.linux-x86_64-cpython-37/apex/parallel
creating build/lib.linux-x86_64-cpython-37/apex/fused_dense
copying apex/fused_dense/fused_dense.py -> build/lib.linux-x86_64-cpython-37/apex/fused_dense
copying apex/fused_dense/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/fused_dense
copying apex/mlp/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/mlp
creating build/lib.linux-x86_64-cpython-37/apex/optimizers
copying apex/optimizers/fused_adagrad.py -> build/lib.linux-x86_64-cpython-37/apex/optimizers
copying apex/optimizers/fused_lamb.py -> build/lib.linux-x86_64-cpython-37/apex/optimizers
copying apex/optimizers/fused_mixed_precision_lamb.py -> build/lib.linux-x86_64-cpython-37/apex/optimizers
copying apex/optimizers/fused_adam.py -> build/lib.linux-x86_64-cpython-37/apex/optimizers
copying apex/amp/_process_optimizer.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/utils.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/__version__.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/compat.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/handle.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/_amp_state.py -> build/lib.linux-x86_64-cpython-37/apex/amp
copying apex/amp/scaler.py -> build/lib.linux-x86_64-cpython-37/apex/amp
creating build/lib.linux-x86_64-cpython-37/apex/normalization
copying apex/normalization/fused_layer_norm.py -> build/lib.linux-x86_64-cpython-37/apex/normalization
copying apex/normalization/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/normalization
copying apex/fp16_utils/fp16util.py -> build/lib.linux-x86_64-cpython-37/apex/fp16_utils
copying apex/fp16_utils/fp16_optimizer.py -> build/lib.linux-x86_64-cpython-37/apex/fp16_utils
copying apex/transformer/parallel_state.py -> build/lib.linux-x86_64-cpython-37/apex/transformer
copying apex/transformer/enums.py -> build/lib.linux-x86_64-cpython-37/apex/transformer
copying apex/transformer/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/transformer
copying apex/transformer/microbatches.py -> build/lib.linux-x86_64-cpython-37/apex/transformer
copying apex/RNN/RNNBackend.py -> build/lib.linux-x86_64-cpython-37/apex/RNN
copying apex/RNN/cells.py -> build/lib.linux-x86_64-cpython-37/apex/RNN
copying apex/contrib/multihead_attn/encdec_multihead_attn.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
copying apex/contrib/multihead_attn/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
copying apex/contrib/multihead_attn/mask_softmax_dropout_func.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
copying apex/contrib/multihead_attn/encdec_multihead_attn_func.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
copying apex/contrib/multihead_attn/fast_self_multihead_attn_func.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
copying apex/contrib/multihead_attn/self_multihead_attn.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/multihead_attn
creating build/lib.linux-x86_64-cpython-37/apex/contrib/xentropy
copying apex/contrib/xentropy/softmax_xentropy.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/xentropy
copying apex/contrib/xentropy/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/xentropy
creating build/lib.linux-x86_64-cpython-37/apex/contrib/transducer
copying apex/contrib/transducer/_transducer_ref.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/transducer
copying apex/contrib/transducer/transducer.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/transducer
copying apex/contrib/transducer/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/transducer
creating build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/distributed_fused_adam.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/fused_lamb.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/distributed_fused_lamb.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/fused_adam.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/fused_sgd.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
copying apex/contrib/optimizers/fp16_optimizer.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/optimizers
creating build/lib.linux-x86_64-cpython-37/apex/contrib/layer_norm
copying apex/contrib/layer_norm/layer_norm.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/layer_norm
copying apex/contrib/layer_norm/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/layer_norm
copying apex/contrib/peer_memory/peer_halo_exchanger_1d.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/peer_memory
copying apex/contrib/focal_loss/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/focal_loss
creating build/lib.linux-x86_64-cpython-37/apex/contrib/clip_grad
copying apex/contrib/clip_grad/clip_grad.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/clip_grad
copying apex/contrib/clip_grad/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/clip_grad
creating build/lib.linux-x86_64-cpython-37/apex/contrib/groupbn
copying apex/contrib/groupbn/batch_norm.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/groupbn
copying apex/contrib/groupbn/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/groupbn
creating build/lib.linux-x86_64-cpython-37/apex/contrib/sparsity
copying apex/contrib/sparsity/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/sparsity
copying apex/contrib/sparsity/asp.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/sparsity
copying apex/contrib/sparsity/permutation_lib.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/sparsity
copying apex/contrib/sparsity/sparse_masklib.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/sparsity
creating build/lib.linux-x86_64-cpython-37/apex/contrib/index_mul_2d
copying apex/contrib/index_mul_2d/index_mul_2d.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/index_mul_2d
creating build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu
copying apex/contrib/conv_bias_relu/conv_bias_relu.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu
copying apex/contrib/conv_bias_relu/__init__.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu
error: [Errno 2] No such file or directory
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /data/songyinghao/.conda/envs/dali_apex/bin/python3.7 -u -c '
exec(compile('"'"''"'"''"'"'
This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
- It imports setuptools before invoking setup.py, to enable projects that directly
import from `distutils.core` to work with newer packaging standards.
- It provides a clear error message when setuptools is not installed.
- It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
manifest_maker: standard file '"'"'-c'"'"' not found".
- It generates a shim setup.py, for handling setup.cfg-only projects.
import os, sys, tokenize
try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute `setup.py` since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
filename = __file__
with tokenize.open(__file__) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'/data/songyinghao/apex-master/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' --cpp_ext --cuda_ext bdist_wheel -d /tmp/pip-wheel-hk_25zj_
cwd: /data/songyinghao/apex-master/
Building wheel for apex (setup.py) ... error
ERROR: Failed building wheel for apex
Running setup.py clean for apex
Running command python setup.py clean
torch.__version__ = 1.8.1+cu101
Compiling cuda extensions with
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
from /usr/bin
running clean
removing 'build/lib.linux-x86_64-cpython-37' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.7' does not exist -- can't clean it
**Failed to build apex
ERROR: Could not build wheels for apex, which is required to install pyproject.toml-based projects**
creating build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu copying apex/contrib/conv_bias_relu/conv_bias_relu.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu copying apex/contrib/conv_bias_relu/init.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu error: [Errno 2] No such file or directory error: subprocess-exited-with-error
Would you have more verbose error around the quote above? I would recommend recent PyTorch as 1.8.1 would be a bit too old.
creating build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu copying apex/contrib/conv_bias_relu/conv_bias_relu.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu copying apex/contrib/conv_bias_relu/init.py -> build/lib.linux-x86_64-cpython-37/apex/contrib/conv_bias_relu error: [Errno 2] No such file or directory error: subprocess-exited-with-error
Would you have more verbose error around the quote above? I would recommend recent PyTorch as 1.8.1 would be a bit too old.
Thank you very much for your reply! you're right. Pytorch1.8.1 is indeed a bit old. But I don't have permission to upgrade cuda, so I can only use pytorch1.8.1. My solution is to use the older brach 22.04-dev. This problem has been solved.
excuse me, the same thing happened to me. Can you tell me more about how to do it?
excuse me, the same thing happened to me. Can you tell me more about how to do it?
- clone or download apex 22.04-dev branch instead of master brach
- use the command:
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./to install 'apex'. Good luck!
I got the same error, solved by "apt-get install python-dev".
@Rainbowman0 I followed your steps, got this error trace
Pytorch version: 2.0.1+cu117 , Python 3.10.12 | packaged by conda-forge
Running command pip subprocess to install build dependencies
Collecting setuptools
Using cached setuptools-68.0.0-py3-none-any.whl
Collecting wheel
Using cached wheel-0.41.0-py3-none-any.whl
Installing collected packages: wheel, setuptools
Successfully installed setuptools-68.0.0 wheel-0.41.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
Traceback (most recent call last):
File "/scratch/nhd7682/envs_dirs/accessory/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/scratch/nhd7682/envs_dirs/accessory/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/scratch/nhd7682/envs_dirs/accessory/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/state/partition1/job-35928918/pip-build-env-r4yfsizq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/state/partition1/job-35928918/pip-build-env-r4yfsizq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/state/partition1/job-35928918/pip-build-env-r4yfsizq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 5, in <module>
ModuleNotFoundError: No module named 'packaging'
Hi @dhyani15 Did you solve this issue?
excuse me, the same thing happened to me. Can you tell me more about how to do it?
- clone or download apex 22.04-dev branch instead of master brach
- use the command:
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./to install 'apex'. Good luck!
It truely works for me! I really appreciate!
Hi@Rainbowman0 Did you solve this issue?
I got the same error, solved by "apt-get install python-dev". @Fizzbb Could you share your package details? thanks in advance! 1, torch version 2, python version 3, cuda version My envs: torch 2.1, py 3.10, cuda 11.8, ubuntu 20.04, I has the same apex install error. the 22.04-dev branch and "apt-get install python-dev" also failed to install.
excuse me, the same thing happened to me. Can you tell me more about how to do it?
- clone or download apex 22.04-dev branch instead of master brach
- use the command:
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./to install 'apex'. Good luck!It truely works for me! I really appreciate! @jhq1234 could you share your packages' details? thanks !! torch/python/cuda version, etc? I has the same problem to install apex. My envs: torch 2.1, py 3.10, cuda 11.8, ubuntu 20.04 @dhyani15, did you solve your problem, I also use torch 2.*. thanks!
python 3.10.11 pytorch 2.1.1 Didnt work for me, having the same issue with -> ERROR: Could not build wheels for nvidia-pyindex, which is required to install pyproject.toml-based projects
excuse me, the same thing happened to me. Can you tell me more about how to do it?
1. clone or download [apex 22.04-dev branch](https://github.com/NVIDIA/apex/tree/22.04-dev) instead of [master brach](https://github.com/nvidia/apex) 2. use the command:`pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./` to install 'apex'. Good luck!
It truly works for me! Pytorch version 1.8.2, CUDA version 11.1, Ubuntu 18.02. Thank you very much!
excuse me, the same thing happened to me. Can you tell me more about how to do it?
- clone or download apex 22.04-dev branch instead of master brach
- use the command:
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./to install 'apex'. Good luck!
still have the same error with your solving method.
excuse me, the same thing happened to me. Can you tell me more about how to do it?
1. clone or download [apex 22.04-dev branch](https://github.com/NVIDIA/apex/tree/22.04-dev) instead of [master brach](https://github.com/nvidia/apex) 2. use the command:`pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./` to install 'apex'. Good luck!It truly works for me! Pytorch version 1.8.2, CUDA version 11.1, Ubuntu 18.02. Thank you very much!
hello, could I know your version of pip? I still didn't solve it.
excuse me, the same thing happened to me. Can you tell me more about how to do it?
1. clone or download [apex 22.04-dev branch](https://github.com/NVIDIA/apex/tree/22.04-dev) instead of [master brach](https://github.com/nvidia/apex) 2. use the command:`pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./` to install 'apex'. Good luck!It truly works for me! Pytorch version 1.8.2, CUDA version 11.1, Ubuntu 18.02. Thank you very much!
hello, could I know your version of
pip? I still didn't solve it.
Sure, my pip version is 23.3.1
excuse me, the same thing happened to me. Can you tell me more about how to do it?
1. clone or download [apex 22.04-dev branch](https://github.com/NVIDIA/apex/tree/22.04-dev) instead of [master brach](https://github.com/nvidia/apex) 2. use the command:`pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./` to install 'apex'. Good luck!It truly works for me! Pytorch version 1.8.2, CUDA version 11.1, Ubuntu 18.02. Thank you very much!
hello, could I know your version of
pip? I still didn't solve it.Sure, my pip version is 23.3.1
Did you solve it? my env is same with you..
excuse me, the same thing happened to me. Can you tell me more about how to do it?
1. clone or download [apex 22.04-dev branch](https://github.com/NVIDIA/apex/tree/22.04-dev) instead of [master brach](https://github.com/nvidia/apex) 2. use the command:`pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./` to install 'apex'. Good luck!It truly works for me! Pytorch version 1.8.2, CUDA version 11.1, Ubuntu 18.02. Thank you very much!
hello, could I know your version of
pip? I still didn't solve it.Sure, my pip version is 23.3.1
Did you solve it? my env is same with you..
Yeah, I solved it. I can successfully build apex now
@EviKulker hi ,My situation is the same as yours. Have you solved this problem now?