PySyft icon indicating copy to clipboard operation
PySyft copied to clipboard

Can't import syft, can't run example federated learning model centric

Open intrivil opened this issue 3 years ago • 5 comments

  1. 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)

  1. 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.

intrivil avatar May 31 '21 08:05 intrivil

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?

intrivil avatar Jun 01 '21 08:06 intrivil

I have the same error: `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 import syft 2 print(syft. version)

~\anaconda3\envs\pysyft\lib\site-packages\syft_init_.py in 59 from syft.core.common.serde.serialize import _serialize as serialize # noqa: F401 60 from syft.core.node.common.service.repr_service import ReprMessage # noqa: F401 ---> 61 from syft.core.node.device.device import Device # noqa: F401 62 from syft.core.node.device.device import DeviceClient # noqa: F401 63 from syft.core.node.domain.domain import Domain # noqa: F401

~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\device_init_.py in 1 # syft relative ----> 2 from .client import DeviceClient 3 from .device import Device 4 5 all = ["DeviceClient", "Device"]

~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\device\client.py in 14 from ...io.location import SpecificLocation 15 from ...io.route import Route ---> 16 from ..common.client import Client 17 18

~\anaconda3\envs\pysyft\lib\site-packages\syft\core\node\common\client.py in 18 from ....core.pointer.pointer import Pointer 19 from ....decorators import syft_decorator ---> 20 from ....lib import lib_ast 21 from ....proto.core.node.common.client_pb2 import Client as Client_PB 22 from ....proto.core.node.common.metadata_pb2 import Metadata as Metadata_PB

~\anaconda3\envs\pysyft\lib\site-packages\syft\lib_init_.py in 24 25 # constructor: copyType = create_lib_ast ---> 26 lib_ast = create_lib_ast() 27 lib_ast._copy = create_lib_ast

~\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' `

nrakurniawan avatar Jun 01 '21 10:06 nrakurniawan

Hi @intrivil and @nrakurniawan, it worked for me when I installed PySyft in a newer version:

pip install syft==0.5.0rc1

LSnyd avatar Jun 01 '21 15:06 LSnyd

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!

arnewitt avatar Jun 02 '21 21:06 arnewitt

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,

intrivil avatar Jun 03 '21 03:06 intrivil

0.5 is no longer supported.

madhavajay avatar Nov 17 '22 07:11 madhavajay