Closed3

Tensorflowを使ってFedarated Learningを試す

Shige OsadaShige Osada

インストール方法

公式を見よう。
https://www.tensorflow.org/federated/install

Linuxの場合

環境:
OS Ubuntu 18.04.5 LTS(Bionic Beaver)
Python  2.7.17
Python3 3.6.9
virtualenv 15.1.0 (環境破壊する可能性あるので~)

モジュール設定:
<OS>
sudo apt update
sudo apt install python3-dev python3-pip # Python 3
<virtualenv>
sudo pip3 install --user --upgrade virtualenv
virtualenv --python python3 "venv"
source "venv/bin/activate"
<TensorFlow Federated>
pip install --upgrade pip
pip install --upgrade tensorflow_federated
python -c "import tensorflow_federated as tff; print(tff.federated_computation(lambda: 'Hello World')())"

macの場合

OS: 10.15.7 Catalina
Python 2.7.16
Python3 3.8.2

設定

% brew update
% brew install python  # Python 3 に関して、Python3以外の周辺系がインストールされる
% pip3 install --user --upgrade virtualenv  

公式ではsudoを指定しているが、不要か。sudoすると、virtualenvの入っているディレクトリにパスを通す(または権限の変更)を必要が出てくる。あんまりroot権限を使いたくないので、これで十分。

% virtualenv --python python3 "venv" # Python3をベースにしたvenvという名前の作業ディレクトリを作成
% source "venv/bin/activate" # venvディレクトリ内の設定をロードし、virtualenvモードに移行 
  # プロンプトの前に(venv) が出る。
(venv) % pip install --upgrade pip
(venv) % pip install --upgrade tensorflow_federated

ここでエラーがでる。

Collecting tensorflow_federated
  Downloading tensorflow_federated-0.17.0-py2.py3-none-any.whl (517 kB)
     |████████████████████████████████| 517 kB 4.4 MB/s 
  Downloading tensorflow_federated-0.16.1-py2.py3-none-any.whl (475 kB)
     |████████████████████████████████| 475 kB 4.8 MB/s 
  Downloading tensorflow_federated-0.16.0-py2.py3-none-any.whl (477 kB)
     |████████████████████████████████| 477 kB 6.5 MB/s 
  Downloading tensorflow_federated-0.15.0-py2.py3-none-any.whl (465 kB)
     |████████████████████████████████| 465 kB 9.5 MB/s 
  Downloading tensorflow_federated-0.14.0-py2.py3-none-any.whl (452 kB)
     |████████████████████████████████| 452 kB 10.3 MB/s 
  Downloading tensorflow_federated-0.13.1-py2.py3-none-any.whl (428 kB)
     |████████████████████████████████| 428 kB 9.6 MB/s 
  Downloading tensorflow_federated-0.13.0-py2.py3-none-any.whl (427 kB)
     |████████████████████████████████| 427 kB 9.3 MB/s 
  Downloading tensorflow_federated-0.12.0-py2.py3-none-any.whl (419 kB)
     |████████████████████████████████| 419 kB 8.8 MB/s 
  Downloading tensorflow_federated-0.11.0-py2.py3-none-any.whl (385 kB)
     |████████████████████████████████| 385 kB 10.5 MB/s 
  Downloading tensorflow_federated-0.10.1-py2.py3-none-any.whl (393 kB)
     |████████████████████████████████| 393 kB 10.7 MB/s 
  Downloading tensorflow_federated-0.10.0-py2.py3-none-any.whl (393 kB)
     |████████████████████████████████| 393 kB 9.3 MB/s 
  Downloading tensorflow_federated-0.9.0-py2.py3-none-any.whl (387 kB)
     |████████████████████████████████| 387 kB 9.5 MB/s 
  Downloading tensorflow_federated-0.7.0-py2.py3-none-any.whl (308 kB)
     |████████████████████████████████| 308 kB 8.1 MB/s 
  Downloading tensorflow_federated-0.6.0-py2.py3-none-any.whl (256 kB)
     |████████████████████████████████| 256 kB 9.7 MB/s 
  Downloading tensorflow_federated-0.5.0-py2.py3-none-any.whl (228 kB)
     |████████████████████████████████| 228 kB 10.5 MB/s 
  Downloading tensorflow_federated-0.4.0-py2.py3-none-any.whl (199 kB)
     |████████████████████████████████| 199 kB 10.8 MB/s 
  Downloading tensorflow_federated-0.3.0-py2.py3-none-any.whl (184 kB)
     |████████████████████████████████| 184 kB 7.0 MB/s 
  Downloading tensorflow_federated-0.2.0-py2.py3-none-any.whl (184 kB)
     |████████████████████████████████| 184 kB 9.8 MB/s 
  Downloading tensorflow_federated-0.1.0-py2.py3-none-any.whl (180 kB)
     |████████████████████████████████| 180 kB 4.3 MB/s 
ERROR: Cannot install tensorflow-federated==0.1.0, tensorflow-federated==0.10.0, tensorflow-federated==0.10.1, tensorflow-federated==0.11.0, tensorflow-federated==0.12.0, tensorflow-federated==0.13.0, tensorflow-federated==0.13.1, tensorflow-federated==0.14.0, tensorflow-federated==0.15.0, tensorflow-federated==0.16.0, tensorflow-federated==0.16.1, tensorflow-federated==0.17.0, tensorflow-federated==0.2.0, tensorflow-federated==0.3.0, tensorflow-federated==0.4.0, tensorflow-federated==0.5.0, tensorflow-federated==0.6.0, tensorflow-federated==0.7.0 and tensorflow-federated==0.9.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    tensorflow-federated 0.17.0 depends on tensorflow-addons~=0.11.1
    tensorflow-federated 0.16.1 depends on tensorflow~=2.2.0
    tensorflow-federated 0.16.0 depends on tensorflow~=2.2.0
    tensorflow-federated 0.15.0 depends on tensorflow~=2.2.0
    tensorflow-federated 0.14.0 depends on tensorflow-addons~=0.9.1
    tensorflow-federated 0.13.1 depends on tensorflow-addons~=0.8.3
    tensorflow-federated 0.13.0 depends on tensorflow-addons~=0.8.3
    tensorflow-federated 0.12.0 depends on tensorflow-addons~=0.7.0
    tensorflow-federated 0.11.0 depends on tensorflow-addons~=0.6.0
    tensorflow-federated 0.10.1 depends on tensorflow-addons~=0.6.0
    tensorflow-federated 0.10.0 depends on tensorflow~=2.0.0
    tensorflow-federated 0.9.0 depends on tf-nightly
    tensorflow-federated 0.7.0 depends on tf-nightly
    tensorflow-federated 0.6.0 depends on tf-nightly
    tensorflow-federated 0.5.0 depends on tf-nightly
    tensorflow-federated 0.4.0 depends on tensorflow~=1.13
    tensorflow-federated 0.3.0 depends on tensorflow~=1.13
    tensorflow-federated 0.2.0 depends on tensorflow~=1.13
    tensorflow-federated 0.1.0 depends on tensorflow>=1.13.0rc2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

なんぞ。

このスクラップは2021/01/03にクローズされました