apex: `pyproject.toml` missing `packaging` dependency
Describe the Bug
#1669 adds a pyproject.toml
file, but the build dependencies are underspecified. The setup.py
file depends on packaging
but this dependency isn’t declared in the build dependencies.
Minimal Steps/Code to Reproduce the Bug
#!/bin/bash
set -euo pipefail
set -x
tmpdir=$(mktemp -d)
conda create -p $tmpdir/env -c pytorch -c nvidia --yes python=3.10 pytorch pytorch-cuda=11.8
conda init bash
conda activate $tmpdir/env
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" git+https://github.com/NVIDIA/apex.git@2d8302a6c12e202f7b40b13a43daa95f326fd0ea
yields
Traceback (most recent call last):
File "/tmp/tmp.DhZuKHLF3V/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/tmp/tmp.DhZuKHLF3V/env/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 "/tmp/tmp.DhZuKHLF3V/env/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 "/tmp/pip-build-env-x0zi0j0a/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 "/tmp/pip-build-env-x0zi0j0a/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-x0zi0j0a/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 4, in <module>
ModuleNotFoundError: No module named 'packaging'
error: subprocess-exited-with-error
full log: https://gist.github.com/calebho/35fa3bf2fdc4e818bc5bded4456988c3
Expected Behavior
It should install without errors
Environment
Collecting environment information...
PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31
Python version: 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-124-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: Quadro GP100
GPU 1: Quadro GP100
Nvidia driver version: 470.141.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 80
On-line CPU(s) list: 0-79
Thread(s) per core: 2
Core(s) per socket: 20
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Gold 6230 CPU @ 2.10GHz
Stepping: 7
CPU MHz: 1708.821
CPU max MHz: 3900.0000
CPU min MHz: 800.0000
BogoMIPS: 4200.00
Virtualization: VT-x
L1d cache: 1.3 MiB
L1i cache: 1.3 MiB
L2 cache: 40 MiB
L3 cache: 55 MiB
NUMA node0 CPU(s): 0-19,40-59
NUMA node1 CPU(s): 20-39,60-79
Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
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
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; TSX disabled
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 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 cdp_l3 invpcid_single intel_ppin 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 mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Versions of relevant libraries:
[pip3] torch==2.0.1
[conda] No relevant packages
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 2
- Comments: 44 (3 by maintainers)
Commits related to this issue
- Use Older Version of Apex The latest version of apex currently does not install, as mentioned here https://github.com/facebookresearch/ConvNeXt-V2/issues/52. This issue with apex has also been rep... — committed to akhilkedia/ConvNeXt-V2 by akhilkedia a year ago
- Fix installation command `--build-option` is not the correct config settings to use; we need `--global-option`. Ref #1679. — committed to janEbert/apex by janEbert a year ago
- Fix installation command `--build-option` is not the correct config setting to use; we need `--global-option`. Ref #1679. — committed to janEbert/apex by janEbert a year ago
pip install -v --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--deprecated_fused_adam" --global-option="--xentropy" --global-option="--fast_multihead_attn" ./
it’s works for me!I think the README is simply wrong. You need to use
--global-option
instead of--build-option
. Here’s the fixed installation command, adapted from the README:Personally I recommend using
--no-build-isolation
as evenpackaging
is installed, I guess it would be a bit tricky to install the same torch as in the environment into a build environment.@VarunGumma try
git checkout 23.05
before installation and then run pip installation command, this is work fine for me.Try with
--no-build-isolation
.@Colezwhy and @crcrpar - when I build with
--no-build-isolation
I don’t get the packaging error, but neither the cpp nor cuda_ext are installed. And no warnings for reasons why they weren’t either.Sample build here that installs apex with
--no-build-isolation
and there are no nvcc lines in the apex install, and later onamp_C
cannot be foundBut then I get this error:
ModuleNotFoundError: No module named 'fused_layer_norm_cuda'
I have solved it. It raises because the cuda installed by conda is not complete, and there’s no
nvcc
. The solution is to install thenvcc
by:and by the way, if still not ok, one can try:
I’ve been experiencing the precise same issues as @loadams
@xwang233 - Are you using the most up to date master branch from the repo? Since you should also need to add packaging and torch as dependencies to the pyproject.toml first, right?
Here is my output:
And this hasn’t built amp_C or apex_C.
Something like this should work for multiple extensions
same issue in
transformers
CI (during docker image build):I encountered the same error, when i added packaging and torch to pyproject.toml, a new error occurred:
my conda env is torch1.7.1, cuda 11.0, and using the 22.04branch for installation.