1*14675a02SAndroid Build Coastguard Worker# Instructions for getting the Federated Compute Platform code up and running on your own machine. 2*14675a02SAndroid Build Coastguard Worker 3*14675a02SAndroid Build Coastguard Worker## Download and install build dependencies 4*14675a02SAndroid Build Coastguard Worker 5*14675a02SAndroid Build Coastguard Worker### Basic tools 6*14675a02SAndroid Build Coastguard Worker 7*14675a02SAndroid Build Coastguard WorkerThere are some basic tools and packages you will need on your machine: 8*14675a02SAndroid Build Coastguard Worker 9*14675a02SAndroid Build Coastguard Worker* Git 10*14675a02SAndroid Build Coastguard Worker* A C++ compiler (e.g., Clang or GCC, but see note about GCC below) 11*14675a02SAndroid Build Coastguard Worker* Python 3.9 or greater, including the `venv` module 12*14675a02SAndroid Build Coastguard Worker 13*14675a02SAndroid Build Coastguard WorkerFor example, on Debian: 14*14675a02SAndroid Build Coastguard Worker 15*14675a02SAndroid Build Coastguard Worker``` 16*14675a02SAndroid Build Coastguard Workersudo apt install -y git gcc python3 python3-dev python3-venv 17*14675a02SAndroid Build Coastguard Worker``` 18*14675a02SAndroid Build Coastguard Worker 19*14675a02SAndroid Build Coastguard Worker> ⚠️ The project maintainers internally test with Clang only, so support for 20*14675a02SAndroid Build Coastguard Worker> GCC-based builds is provided only on a best-effort basis and may at times be 21*14675a02SAndroid Build Coastguard Worker> broken. 22*14675a02SAndroid Build Coastguard Worker> 23*14675a02SAndroid Build Coastguard Worker> If using GCC then we recommend using a recent version (e.g., at least as 24*14675a02SAndroid Build Coastguard Worker> recent as what Debian stable uses, preferably newer than that). 25*14675a02SAndroid Build Coastguard Worker> 26*14675a02SAndroid Build Coastguard Worker> If using Clang then please see [Building with Clang](#building-with-clang) for 27*14675a02SAndroid Build Coastguard Worker> further Clang-specific instructions. 28*14675a02SAndroid Build Coastguard Worker 29*14675a02SAndroid Build Coastguard Worker### Install Bazelisk 30*14675a02SAndroid Build Coastguard Worker 31*14675a02SAndroid Build Coastguard WorkerBazelisk is used to fetch the correct Bazel binaries necessary to build and run 32*14675a02SAndroid Build Coastguard WorkerFederated Compute code. 33*14675a02SAndroid Build Coastguard Worker 34*14675a02SAndroid Build Coastguard WorkerPlease read https://github.com/bazelbuild/bazelisk#installation. 35*14675a02SAndroid Build Coastguard Worker 36*14675a02SAndroid Build Coastguard Worker## Set up your Python environment 37*14675a02SAndroid Build Coastguard Worker 38*14675a02SAndroid Build Coastguard WorkerSetting up a virtual Python environment will ensure that Python dependencies 39*14675a02SAndroid Build Coastguard Workerdon't conflict or overwrite your existing Python installation. If you have 40*14675a02SAndroid Build Coastguard Workermultiple installed versions of Python, replace `python3` in the following 41*14675a02SAndroid Build Coastguard Workerinstructions with the desired version (e.g., `python3.X`). 42*14675a02SAndroid Build Coastguard Worker 43*14675a02SAndroid Build Coastguard Worker``` 44*14675a02SAndroid Build Coastguard Workerpython3 -m venv venv 45*14675a02SAndroid Build Coastguard Workersource venv/bin/activate 46*14675a02SAndroid Build Coastguard Workerpip install --upgrade pip 47*14675a02SAndroid Build Coastguard Worker``` 48*14675a02SAndroid Build Coastguard Worker 49*14675a02SAndroid Build Coastguard WorkerNote: To exit the virtual environment, run `deactivate`. 50*14675a02SAndroid Build Coastguard Worker 51*14675a02SAndroid Build Coastguard Worker## Clone the Federated Compute repository and install Python requirements 52*14675a02SAndroid Build Coastguard Worker 53*14675a02SAndroid Build Coastguard Worker``` 54*14675a02SAndroid Build Coastguard Workergit clone https://github.com/google/federated-compute.git 55*14675a02SAndroid Build Coastguard Workercd federated-compute 56*14675a02SAndroid Build Coastguard Workerpip install -r requirements.txt 57*14675a02SAndroid Build Coastguard Worker``` 58*14675a02SAndroid Build Coastguard Worker 59*14675a02SAndroid Build Coastguard Worker## Build and run the federated program test! 60*14675a02SAndroid Build Coastguard Worker 61*14675a02SAndroid Build Coastguard Worker> ⚠️ Many Federated Compute targets depend on TensorFlow, which can take several 62*14675a02SAndroid Build Coastguard Worker> hours to build for the first time. Consider running builds in `screen` or 63*14675a02SAndroid Build Coastguard Worker> `tmux` if you're worried about your terminal closing during this time. 64*14675a02SAndroid Build Coastguard Worker> 65*14675a02SAndroid Build Coastguard Worker> While not required, Bazel's 66*14675a02SAndroid Build Coastguard Worker> [remote build execution](https://bazel.build/remote/rbe) and 67*14675a02SAndroid Build Coastguard Worker> [remote caching](https://bazel.build/remote/caching) features can speed up 68*14675a02SAndroid Build Coastguard Worker> builds. 69*14675a02SAndroid Build Coastguard Worker 70*14675a02SAndroid Build Coastguard Worker``` 71*14675a02SAndroid Build Coastguard Workerbazelisk test //fcp/demo:federated_program_test 72*14675a02SAndroid Build Coastguard Worker``` 73*14675a02SAndroid Build Coastguard Worker 74*14675a02SAndroid Build Coastguard Worker### Building with Clang 75*14675a02SAndroid Build Coastguard Worker 76*14675a02SAndroid Build Coastguard WorkerUse `--config=clang` to build with clang and libc++. On Debian, this requires 77*14675a02SAndroid Build Coastguard Workerinstalling several additional packages: 78*14675a02SAndroid Build Coastguard Worker 79*14675a02SAndroid Build Coastguard Worker``` 80*14675a02SAndroid Build Coastguard Workersudo apt install -y clang lld libc++-dev libc++abi-dev` 81*14675a02SAndroid Build Coastguard Worker``` 82