Apex: ImportError: cannot import name 'FP16_Optimizer'

Created on 7 Nov 2019  路  3Comments  路  Source: NVIDIA/apex

I have the some problem when import apex on colab.
the wdir is apex, I execute the code to install apex
!git clone https://github.com/NVIDIA/apex.git
%cd apex
!pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext"

But it seems that it fails to find the path of fp16_optimizer and FusedAdam at optimizer folder
ImportError: cannot import name 'FP16_Optimizer'
ImportError: Please install apex from https://www.github.com/nvidia/apex

Most helpful comment

Are you directly importing FP16_Optimizer in your code?
If so, the current apex version might produce this issue, as FP16_Optimizer was moved to contrib/optimizers.

That being said, FP16_Optimizer is deprecated, so please don't import and use it manually.

Let us know, if that fixes the problem.

All 3 comments

Are you directly importing FP16_Optimizer in your code?
If so, the current apex version might produce this issue, as FP16_Optimizer was moved to contrib/optimizers.

That being said, FP16_Optimizer is deprecated, so please don't import and use it manually.

Let us know, if that fixes the problem.

Yes it fixes the problem, thx!
I was executing code from some outdated example, in which FP16_Optimizer was used.
Thanks for your assistance!

Are you directly importing FP16_Optimizer in your code?
If so, the current apex version might produce this issue, as FP16_Optimizer was moved to contrib/optimizers.

That being said, FP16_Optimizer is deprecated, so please don't import and use it manually.

Let us know, if that fixes the problem.

Thanks for your suggestion so much!
I solve this problem by changing the original code:
Original code: from apex.optimizers import FusedAdam
Correct code: from apex.contrib.optimizers import FusedAdam

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rmrao picture rmrao  路  3Comments

jbraeburn picture jbraeburn  路  4Comments

Data-drone picture Data-drone  路  4Comments

dave-epstein picture dave-epstein  路  3Comments

LightToYang picture LightToYang  路  4Comments