apex icon indicating copy to clipboard operation
apex copied to clipboard

import apex always have AttributeError: module 'torch' has no attribute 'library'

Open Cominder opened this issue 11 months ago • 13 comments

always have Traceback (most recent call last): File "", line 1, in File "/root/apex/apex/init.py", line 26, in from . import normalization File "/root/apex/apex/normalization/init.py", line 1, in from .fused_layer_norm import FusedLayerNorm, MixedFusedLayerNorm, FusedRMSNorm, MixedFusedRMSNorm File "/root/apex/apex/normalization/fused_layer_norm.py", line 70, in if supports_custom_op(): File "/root/apex/apex/normalization/fused_layer_norm.py", line 18, in supports_custom_op return hasattr(torch.library, "custom_op") AttributeError: module 'torch' has no attribute 'library'。

no matter cuda10.1+torch1.6.0/1.7.1 python3.7 or cuda11.1+torch1.8.0 python3.8 or cuda11.3+torch1.10.1 python3.8, apex did nnot work!

Image

Cominder avatar Jan 04 '25 02:01 Cominder

Did you solve it?

GG0614 avatar Jan 05 '25 10:01 GG0614

Did you solve it?  你解决了吗?

NO, still bothers me

Cominder avatar Jan 05 '25 10:01 Cominder

Did you solve it?  你解决了吗?

NO, still bothers me

you can try apex-22.02-parallel-state,I solve this problem just now cuda11.3+torch1.10.1+torchvision0.11.2+torchaudio0.10.1

GG0614 avatar Jan 05 '25 11:01 GG0614

Did you solve it?  你解决了吗?

NO, still bothers me  不,仍然困扰着我

you can try apex-22.02-parallel-state,I solve this problem just now你可以试试apex-22.02-parallel-state,我刚刚解决了这个问题 cuda11.3+torch1.10.1+torchvision0.11.2+torchaudio0.10.1

where to get apex-22.02-parallel-state? I can not find it. and python version? no 22.02

Image

Cominder avatar Jan 05 '25 15:01 Cominder

git clone https://github.com/NVIDIA/apex.git cd apex git tag # if not wanted version git branch -r git checkout origin/22.02-parallel-state # or another vesion python setup.py install --cuda_ext --cpp_ext pip3 install -v --no-cache-dir ./

Cominder avatar Jan 06 '25 05:01 Cominder

git clone https://github.com/NVIDIA/apex.git cd apex git tag # if not wanted version git branch -r git checkout origin/22.02-parallel-state # or another vesion python setup.py install --cuda_ext --cpp_ext pip3 install -v --no-cache-dir ./

yes,you can try

GG0614 avatar Jan 06 '25 05:01 GG0614

git clone https://github.com/NVIDIA/apex.git cd apex git tag # if not wanted version git branch -r git checkout origin/22.02-parallel-state # or another vesion python setup.py install --cuda_ext --cpp_ext pip3 install -v --no-cache-dir ./

Thanks for your answer, I have solved it.

cuda11.3+torch1.10.1+torchvision0.11.2+torchaudio0.10.1

Malloy99 avatar Jan 07 '25 08:01 Malloy99

git clone https://github.com/NVIDIA/apex.git cd apex git tag # if not wanted version git branch -r git checkout origin/22.02-parallel-state # or another vesion python setup.py install --cuda_ext --cpp_ext pip3 install -v --no-cache-dir ./

It works in cuda 11.3, thank you a lot

QLYYLQ avatar Jan 19 '25 21:01 QLYYLQ

我用这个版本成功解决了 git clone https://github.com/ptrblck/apex.git cd apex git checkout apex_no_distributed pip install -v --no-cache-dir ./

rzw520 avatar Feb 03 '25 08:02 rzw520

我用这个版本成功解决了 git clone https://github.com/ptrblck/apex.git cd apex git checkout apex_no_distributed pip install -v --no-cache-dir ./

thank you

chcchc97 avatar Mar 02 '25 15:03 chcchc97

我用这个版本成功解决了 git clone https://github.com/ptrblck/apex.git cd apex git checkout apex_no_distributed pip install -v --no-cache-dir ./

Thanks for sharing! This applies to my conda virtual environment on Ubuntu as well.

ShutaoChen97 avatar Mar 10 '25 05:03 ShutaoChen97

我用这个版本成功解决了 git clone https://github.com/ptrblck/apex.git cd apex git checkout apex_no_distributed pip install -v --no-cache-dir ./

Haha, legendary ptrblck to the rescue. :))

Thanks for sharing the fix, although I checked the differences in the no-distributed branch, it seems the latest version have those changes already. So, I think cloning the original repository (i.e. git clone https://github.com/NVIDIA/apex.git) should also work, imo.

Also, how do people find these fixes?!

Ambuj-Choudha avatar Mar 26 '25 07:03 Ambuj-Choudha

git clone https://github.com/NVIDIA/apex.git cd apex git tag # if not wanted version git branch -r git checkout origin/22.02-parallel-state # or another vesion python setup.py install --cuda_ext --cpp_ext pip3 install -v --no-cache-dir ./

可以成功下载,但是print(apex.version)会显示AttributeError: module 'apex' has no attribute 'version', print(amp._amp_C.file)显示AttributeError: module apex.amp has no attribute _amp_C, 暂时忽略这些错误 ubuntu18.04+cuda10.2+torch1.7.1+torchvision0.8.2

gudin-hub avatar Apr 07 '25 06:04 gudin-hub