PySyft
PySyft copied to clipboard
Can't import syft, can't run example federated learning model centric
- When I install PySyft as describe in https://github.com/OpenMined/PySyft, I got the following error when importing syft as sy: AttributeError: type object 'Tensor' has no attribute 'fft'
(For this, the python version is 3.9, torch 1.8.1, syft 0.3.0)
- I search for this and found a solution: I use this command before the pip install syft:
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
This get me pass the above error. However I encounter the following error when run the mcfl_create_plan_mobile.ipynb in example: (For this, the python version is 3.9, torch 1.7.0, syft 0.3.0)
ModuleNotFoundError Traceback (most recent call last)
in 8 # syft absolute 9 import syft as sy ---> 10 from syft.core.plan.plan_builder import ROOT_CLIENT 11 from syft.core.plan.plan_builder import PLAN_BUILDER_VM 12 from syft.core.plan.plan_builder import make_plan
ModuleNotFoundError: No module named 'syft.core.plan' Now I don't know how to move forward.
Can someone help me ? Basically I just want to run the example federated learning in the packages/syft/examples/federated-learning/model-centric Thank you very much.
To add, I've also tried to install syft with this command: pip install git+https://github.com/OpenMined/PySyft@dev#egg=syft But I encountered the problem: ERROR: File "setup.py" or "setup.cfg" not found for legacy project syft from git+https://github.com/OpenMined/PySyft@dev#egg=syft. I truely don't get it, so many people are using this why I can't even install it?
I have the same error:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\anaconda3\envs\pysyft\lib\site-packages\syft_init_.py in
~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\device_init_.py in
~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\device\client.py in
~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\common\client.py in
~\anaconda3\envs\pysyft\lib\site-packages\syft\lib_init_.py in
~\anaconda3\envs\pysyft\lib\site-packages\syft\lib_init_.py in create_lib_ast() 10 11 python_ast = create_python_ast() ---> 12 torch_ast = create_torch_ast() 13 torchvision_ast = create_torchvision_ast() 14 # numpy_ast = create_numpy_ast()
~\anaconda3\envs\pysyft\lib\site-packages\syft\lib\torch_init_.py in create_torch_ast() 51 # this allows us to import them for testing 52 continue ---> 53 ast.add_path( 54 path=method, framework_reference=torch, return_type_name=return_type 55 )
~\anaconda3\envs\pysyft\lib\site-packages\syft\ast\globals.py in add_path(self, path, index, return_type_name, framework_reference) 63 attr = self.attrs[framework_name] 64 if hasattr(attr, "add_path"): ---> 65 attr.add_path( # type: ignore 66 path=path, index=1, return_type_name=return_type_name 67 )
~\anaconda3\envs\pysyft\lib\site-packages\syft\ast\module.py in add_path(self, path, index, return_type_name, framework_reference) 118 self.lookup_cache[attr_ref] = path 119 if hasattr(attr, "add_path"): --> 120 attr.add_path( # type: ignore 121 path=path, index=index + 1, return_type_name=return_type_name 122 )
~\anaconda3\envs\pysyft\lib\site-packages\syft\ast\callable.py in add_path(self, path, index, return_type_name) 80 if path[index] not in self.attrs: 81 ---> 82 attr_ref = getattr(self.ref, path[index]) 83 84 if isinstance(attr_ref, module_type):
AttributeError: type object 'Tensor' has no attribute 'fft' `
Hi @intrivil and @nrakurniawan, it worked for me when I installed PySyft in a newer version:
pip install syft==0.5.0rc1
Hi @intrivil and @nrakurniawan! As @LSnyd kindly suggested, your problem is with incompatible versions. I would personally recommend downgrading syft to 0.3.0 and torch to 1.7.1, since syft 0.3.0 is incompatible with torch 1.8.1.
This setup proved to be most reliable on my machine. Keep in mind that syft 0.5.0 is still only a release candidate.
pip install syft==0.3.0 torch==1.7.1
Hope that helps! Have a great day!
Hi @LSnyd and @arnewitt , Thank you very much for your reply. I have been able to solve this by either install the latest version (0.5.0rc2) of syft OR downgrading torch to 1.7.1 and use syft 0.3.0. Just to note, the command pip install git+https://github.com/OpenMined/PySyft@dev#egg=syft as suggested in some thread is not working as of the time of this comment. Again thank you. Best regards,
0.5 is no longer supported.