영어 버전 문서로 돌아가기
집계자 (당사자) 에 연결
집계자 (당사자) 에 연결
마지막 업데이트 날짜: 2024년 11월 28일
각 당사자는 다음 단계를 수행하여 시작된 집계자에 연결합니다.
프로젝트를 열고 연합 학습 실험을 클릭하십시오.
설정 정보 보기 를 클릭하고 다운로드 아이콘을 클릭하여 당사자 커넥터 스크립트를 다운로드하십시오.
각 당사자는 당사자 커넥터 스크립트를 구성하고 스크립트를 실행하기 위한 올바른 신임 정보를 제공해야 합니다. 완료된 샘플 당사자 커넥터 스크립트는 다음과 같습니다.
from ibm_watsonx_ai import APIClient wml_credentials = { "url": "https://us-south.ml.cloud.ibm.com", "apikey": "<API KEY>" } wml_client = APIClient(wml_credentials) wml_client.set.default_project("XXX-XXX-XXX-XXX-XXX") party_metadata = { wml_client.remote_training_systems.ConfigurationMetaNames.DATA_HANDLER: { "name": "MnistSklearnDataHandler", "path": "example.mnist_sklearn_data_handler", "info": { "npz_file":"./example_data/example_data.npz" } party = wml_client.remote_training_systems.create_party("XXX-XXX-XXX-XXX-XXX", party_metadata) party.monitor_logs() party.run(aggregator_id="XXX-XXX-XXX-XXX-XXX", asynchronous=False)
매개변수:
api_key
:
IAM API키. 새 API 키를 생성하려면 IBM Cloud 웹사이트로 이동하여 관리 > 액세스(IAM) > API 키에서 IBM Cloud Pak for Data API 키 생성을 클릭합니다.
선택사항: 다른 프로젝트의 스크립트를 재사용하는 경우 설정 정보 창에서 업데이트된
project_id
,aggregator_id
및experiment_id
를 복사하여 스크립트에 복사할 수 있습니다.아직 설치하지 않았다면 최신 연합 학습 패키지와 함께 watsonx.ai Runtime을 설치하세요:
- Mac에서 M-series를 사용하는 경우 다음 스크립트를 사용하여 최신 패키지를 설치하십시오.
# ----------------------------------------------------------------------------------------- # (C) Copyright IBM Corp. 2023. # https://opensource.org/licenses/BSD-3-Clause # ----------------------------------------------------------------------------------------- # # # Script to create a conda environment and install ibm_watsonx_ai with # the dependencies required for Federated Learning on MacOS. # The name of the conda environment to be created is passed as the first argument. # # Note: This script requires miniforge to be installed for conda. # usage=". install_fl_rt23.1_macos.sh conda_env_name" arch=$(uname -m) os=$(uname -s) if (($# < 1)) then echo $usage exit fi ENAME=$1 conda create -y -n ${ENAME} python=3.10 conda activate ${ENAME} pip install ibm_watsonx_ai if [ "$os" == "Darwin" -a "$arch" == "arm64" ] then conda install -y -c apple tensorflow-deps fi python - <<EOF import pkg_resources import platform import subprocess package = 'ibm_watsonx_ai' extra = 'fl-rt23.1-py3.10' extra_ = extra.replace('.','-') extra_s = '; extra == "{}"' remove = None add = [] if platform.system() == "Darwin" and platform.processor() == "arm": remove = 'tensorflow' add = ['tensorflow-macos==2.9.2'] pkgs = pkg_resources.working_set.by_key[package].requires(extras=[extra]) pkgs = [ p.__str__().removesuffix(extra_s.format(extra)).removesuffix(extra_s.format(extra_)) for p in pkgs if ( extra in p.__str__() or extra_ in p.__str__() ) and ( not remove or remove not in p.__str__() )] print( "Installing standard packages for {}[{}]:{}".format(package,extra,pkgs) ) print( "Installing additional packages:{}".format(add) ) cmd = [ 'pip', 'install'] + add + pkgs subprocess.run( cmd ) EOF
- 그렇지 않으면
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ 'ibm_watsonx_ai[fl-rt23.1-py3.10]'
명령을 사용하여 설치하십시오.
구성이 완료되고 당사자 커넥터 스크립트를 저장하면 명령행에 다음 명령을 입력하여 스크립트를 실행하십시오.
python3 rts_<RTS Name>_<RTS ID>.py
추가 리소스
상위 주제: 연합 학습 실험 작성
주제가 도움이 되었습니까?
0/1000