联邦学习虚拟机构建,基于docker-ubuntu:20.04
配置Linux环境
更新软件包
下载MiniCoda
1
| wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.9.2-0-Linux-x86_64.sh
|
安装MiniCoda
1
| bash Miniconda3-py312_24.9.2-0-Linux-x86_64.sh
|
启动环境
这里需要修改.bashrc,否则每次都需要exec(交互式页面)进入之后才能执行~/.bashrc,导致sshd等无法开启,因此,需要修改文件中的这个部分,将其进行注释
配置Python环境
安装Linux-Torch
1
| pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
安装Matplotlib
环境共享化
复制/root/.bashrc
1
| docker cp BS1:/root/.bashrc ./.bashrc
|
复制minicoda环境
1
| docker cp BS1:/root/miniconda3 ./miniconda
|
修改Docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| version: '3.8'
services: BS1: image: ubuntu2004:1.2 container_name: BS1 volumes: - ./BS1:/root/code - ./.bashrc:/root/.bashrc - ./miniconda:/root/miniconda3 networks: DPFL-network: ipv4_address: 192.168.58.3 command: bash --login -c "tail -f /dev/null" BS2: image: ubuntu2004:1.2 container_name: BS2 volumes: - ./BS2:/root/code - ./.bashrc:/root/.bashrc - ./miniconda:/root/miniconda3 networks: DPFL-network: ipv4_address: 192.168.58.4 command: bash --login -c "tail -f /dev/null" BS3: image: ubuntu2004:1.2 container_name: BS3 volumes: - ./BS3:/root/code - ./.bashrc:/root/.bashrc - ./miniconda:/root/miniconda3 networks: DPFL-network: ipv4_address: 192.168.58.5 command: bash --login -c "tail -f /dev/null" CS1: image: ubuntu2004:1.2 container_name: CS1 volumes: - ./CS1:/root/code - ./.bashrc:/root/.bashrc - ./miniconda:/root/miniconda3 networks: DPFL-network: ipv4_address: 192.168.58.6 command: bash --login -c "tail -f /dev/null"
networks: DPFL-network: driver: bridge ipam: driver: default config: - subnet: 192.168.58.0/24
|