Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original ImportError was: ModuleNotFoundError("No module named 'amp_C') #573

Closed
misslibra opened this issue Oct 31, 2019 · 9 comments
Closed

Comments

@misslibra
Copy link

my env is CUDA 10.1, and pytorch 1.3,GPU v100,python 3.6,
and I get error:

Warning: multi_tensor_applier fused unscale kernel is unavailable, possibly because apex was installed without --cuda_ext --cpp_ext. Using Python fallback. Original ImportError was: ModuleNotFoundError("No module named 'amp_C'",)
Traceback (most recent call last):
File "train.py", line 104, in
lr_scheduler = config_lr_scheduler(args, optimizer)
File "/home/perception/Documents/apex-master/geely_yolo3D/utils/utils.py", line 553, in config_lr_scheduler
return torch.optim.lr_scheduler.StepLR(optimizer, args.lr_decay_epoch, args.gamma)
File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 208, in init
super(StepLR, self).init(optimizer, last_epoch)
File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 58, in init
self.optimizer.step = with_counter(self.optimizer.step)
File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 40, in with_counter
instance_ref = weakref.ref(method.self)
AttributeError: 'function' object has no attribute 'self'

My code run well in env : CUDA 9,pytorch 1.2,GPU P4000,python 3.6

Please help me with this issue.

@mcarilli
Copy link
Contributor

Should by fixed by #553. Try puling the latest master and reinstalling:

apex $ git pull
apex $ pip uninstall apex # repeat until you're sure it's gone
apex $ pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

@misslibra
Copy link
Author

Thanks for your reply !
I download code zip yesterday ,which should be the latest version.
and I have fixed the problem by pip install using pip in conda--bin install of pip default .

@soodeh-nilforoushan
Copy link

Hi, I did not understand how you fix this error? I was stuck for two days for this error, if someone can help me, I would be happy!

@CRaimondo
Copy link

Also getting this error and not sure how you fixed @misslibra

@JoshLuxton
Copy link

JoshLuxton commented Nov 10, 2021

Phew. this was hard to get working.

To the couple new commenters from the past week - this won't work in an environment with cuda-tookit-11+ you will need cuda-toolkit-10-2.

don't touch your cuda drivers just follow the instructions here: https://www.mathworks.com/matlabcentral/answers/687133-how-to-install-supported-cuda-toolkit-10-2-on-ubuntu-20-04-lts-linux

when it references: https://developer.nvidia.com/cuda-10.2-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork

follow all steps from the archive EXCEPT when it says to install cuda (this will overwrite your drivers and cause incompatibility). Instead, install cuda-toolkit-10-2

this should update nvcc -V to reference 10.2, but if it doesnt check /usr/local/cuda:

ls -la /usr/local/cuda*

often multiple toolkits can live there.. and often you will see a symlink from /usrl/local/cuda to whichever version of cuda nvcc will reference for compile (you can replace the symlink to your desired version).

after that is setup and you follow the instructions for setting alternative gcc version you can proceed with the install listed in mcarills comment from Oct 31, 2019

@alexqdh
Copy link

alexqdh commented Jun 21, 2023

After install apex, it still has some errors

  1. ModuleNotFoundError: No module named 'packaging' Error occurs when build apex latest code. I checkout the previous one to fix it.
git clone https://github.com/NVIDIA/apex
cd apex
git checkout 22.04-dev
pip install -r requirements.txt
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
  1. ImportError: libc10.so. It should import torch before amp_C, use like this:
import torch
import amp_C

Install torch-1.12.1 gpu version:

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113

@liaochuanlin
Copy link

ERROR: Could not build wheels for apex, which is required to install pyproject.toml-based projects

@ming-afk
Copy link

ERROR: Could not build wheels for apex, which is required to install pyproject.toml-based projects

maybe try this:
#1594 (comment)

@hayatkhan8660-maker
Copy link

hayatkhan8660-maker commented May 25, 2024

my env is CUDA 10.1, and pytorch 1.3,GPU v100,python 3.6, and I get error:

Warning: multi_tensor_applier fused unscale kernel is unavailable, possibly because apex was installed without --cuda_ext --cpp_ext. Using Python fallback. Original ImportError was: ModuleNotFoundError("No module named 'amp_C'",) Traceback (most recent call last): File "train.py", line 104, in lr_scheduler = config_lr_scheduler(args, optimizer) File "/home/perception/Documents/apex-master/geely_yolo3D/utils/utils.py", line 553, in config_lr_scheduler return torch.optim.lr_scheduler.StepLR(optimizer, args.lr_decay_epoch, args.gamma) File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 208, in init super(StepLR, self).init(optimizer, last_epoch) File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 58, in init self.optimizer.step = with_counter(self.optimizer.step) File "/home/perception/anaconda3/envs/new/lib/python3.6/site-packages/torch/optim/lr_scheduler.py", line 40, in with_counter instance_ref = weakref.ref(method.self) AttributeError: 'function' object has no attribute 'self'

My code run well in env : CUDA 9,pytorch 1.2,GPU P4000,python 3.6

Please help me with this issue.

@misslibra
Have you solved this issue?

I am having the same issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants