AttributeError: module 'syft' has no attribute 'TorchHook'

8.4k Views Asked by At

Please seeking help from expert: When I am using pysyft library in python I am getting this error ( AttributeError: module 'syft' has no attribute 'TorchHook')

Here is my code screenshot [1]: https://i.stack.imgur.com/rPxWw.png

my environment : Spyder (Python IDE) Ubuntu 20.04 python3

2

There are 2 best solutions below

2
On BEST ANSWER

The version of syft you are using is v0.3.0+. It does not contain syft.TorchHook as I believe I read that it is not needed there. Use pip install syft==0.2.9 to use syft.TorchHook(). Especially if you are following that Secure and Private Course from Andrew Trask, Openmined.

Note that if you are indeed following that course, a new updated course has been introduced by the Openmined team. See https://courses.openmined.org/courses/foundations-of-private-computation for more details. It is based on an updated version of syft.

0
On

I would like to add one additional issue: if you found the following problem when using PIP install syft==0.2.9

Could not find a version that satisfies the requirement torch~=1.4.0 (from syft) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)

You can refer to the following methods to solve:

pip install syft -f https://download.pytorch.org/whl/torch_stable.html

Reason:

  1. Not all PyTorch versions are available on Python's package registry PyPI.

  2. -f : adding the custom registry

    -f, --find-links <url>

    If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files. If a local path or file:// URL that’s a directory, then look for archives in the directory listing. Links to VCS project URLs are not supported.

  3. refer to this link