Hi,
I can import amp from /apex directory but not from any other location. I installed it using the following command:
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
but I still get the following error:

Thanks!
There may still be some python import weirdness going on. Try moving apex out of your training directory hierarchy, to a completely different location.
Hi,
Thanks for your suggestion but it did not work.
from apex import amp works only when present in apex directory. I am wondering how to make it global because pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ isn't helping either.
Thanks!
@vr25 were you able to find a solution?
@vinhngx do you know how to resolve this?
@vr25 this solved the issue for me.
Hi @vr25,
I had the same problem and my solution is:
Check the version of pytorch with cuda compatibility
nvcc --version or in usr/local/cuda-[version]pip install torch==1.4+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.htmlYou can now install apex with this as @seedlit has mentioned.
I hope this would help
a dirty way would also be to: cp -r apex/apex/ ~/.local/lib/python3.7/site-packages/
and don't forget to source ~/.profile/
Automatic Mixed Precision package is now available within Pytorch (1.6 unstable develope preview).
Check this out.
Hi @vr25,
I had the same problem and my solution is:
Check the version of
pytorchwithcudacompatibility
- To check your cuda version:
nvcc --versionor inusr/local/cuda-[version]- If your CUDA is 10.0, please re-check your pytorch with cuda here
- Then, install/re-install with
pip install torch==1.4+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html- You can now install apex with this as @seedlit has mentioned.
I hope this would help
hi i completely follow your setp and it shows install success.
when i use "from apex import amp" it does work but i still can't use "from torch.cuda import amp" is shows error message can't import .
and here is my server message : cuda version 10.0.130 /graphics: GTX1080 & GTX titan X/pytorch.version.cuda==10.0
do you have any idea on how i could fix this problem? many thanks
There may still be some python import weirdness going on. Try moving apex out of your training directory hierarchy, to a completely different location.
On moving the apex folder to /home folder and installing it again using the instructions from here, I was able to use it successfully.
Most helpful comment
Hi @vr25,
I had the same problem and my solution is:
Check the version of
pytorchwithcudacompatibilitynvcc --versionor inusr/local/cuda-[version]pip install torch==1.4+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.htmlYou can now install apex with this as @seedlit has mentioned.
I hope this would help