pytorch / opacus

Training PyTorch models with differential privacy
https://opacus.ai
Apache License 2.0
1.65k stars 328 forks source link

ImportError: cannot import name 'DifferentiallyPrivateDistributedDataParallel' from 'opacus.layers' #597

Closed Ethan-Chen-plus closed 8 months ago

Ethan-Chen-plus commented 1 year ago
from opacus.layers import DifferentiallyPrivateDistributedDataParallel as DPDDP
ImportError: cannot import name 'DifferentiallyPrivateDistributedDataParallel' from 'opacus.layers' (/root/anaconda3/envs/LLM/lib/python3.11/site-packages/opacus/layers/__init__.py)
lucamelis commented 1 year ago

It's not an issue on v1.3.0+. It seems like opacus has not been installed properly.

karthikprasad commented 11 months ago

Did the reinstallation work for you @Ethan-Chen-plus? If not, could you share a collab that reproduces this?

Ethan-Chen-plus commented 11 months ago

image

karthikprasad commented 11 months ago

@Ethan-Chen-plus , apologies, but I am not sure what to make of the above screenshot. Could you provide a link to a colab that I can run and reproduce the error?

divyanshugit commented 9 months ago

@Ethan-Chen-plus There has been a change in Opacus structure. The DPDDP thing has been moved out of opacus.layers to opacus.distributed. Now, you can use:

from opacus.distributed import DifferentiallyPrivateDistributedDataParallel as DPDDP
HuanyuZhang commented 8 months ago

I suppose you have solved the issue. Feel free to re-open it if you still need it.