导入apex报错AttributeError: module ‘torch‘ has no attribute ‘library‘
使用torch==1.11.0+cu113会报错
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'。
解决方法:
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 ./