apex
apex copied to clipboard
ImportError: cannot import name 'amp'
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
withcuda
compatibility- To check your cuda version:
nvcc --version
or 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
- To check your cuda version:
-
You 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
pytorch
withcuda
compatibility
- To check your cuda version:
nvcc --version
or 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.
a dirty way would also be to:
cp -r apex/apex/ ~/.local/lib/python3.7/site-packages/
and don't forget to source ~/.profile/
Thanks, it works
hello,我的问题是使用nvcc --version检测的版本是下面的,报错了ImportError: cannot import name 'amp' from 'torch.cuda',求指导,谢谢! nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Sun_Jul_28_19:07:16_PDT_2019 Cuda compilation tools, release 10.1, V10.1.243
@Mrgorlay
Hi @vr25, I had the same problem and my solution is:
Check the version of
pytorch
withcuda
compatibility
- To check your cuda version:
nvcc --version
or 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
Cuda 和 PyTorch 版本应该互相支持
你可以尝试安装
# CUDA 10.1
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
然后,再次安装 Apex