Alibaba-Gemini-Lab / OpenCheetah

189 stars 48 forks source link

How to use the throttle.sh to mimic an WAN setting in SPU library? #39

Open warpoons opened 5 months ago

warpoons commented 5 months ago

Hi. Dear Cheetah developers!

Currently, I am interested in evaluating the private inference cost of ResNet18 using the SecretFlow-SPU library. Since the flax resnet example simulates multiple parties via multiple processes within one machine (as said here ). To ensure a fair comparison, I have to simulate an LAN setting with specific bandwidth and ping latency ,but simulating such a network may need the use of docker or VMs. Is there a way to use the scripts/throttle.sh to do this within one machine, while free the use of docker or VMs?

My test environment is WLS2 and for SPU testing I usually launch two terminals in PyCharm. One for the SPU backend runtime: image and one for the inference.py. image

For example, is it correct to run sudo scripts/throttle.sh lan before I run the above commands? Do I need to launch another terminal to run this command in advance? Or run this command on which one of the above two terminals?

Please forgive me for not being very familiar with the Linux traffic control tool. Sorry for taking your time. Thanks.

BTW, there are the following lines in the throttle.sh:

## replace DEV=lo with your card (e.g., eth0)
DEV=lo

Why do I need to replace DEV specifically? Because in 2pc.json in SPU, there are several IPs and I am not sure about which one should be placed here. Thanks. If not, how can I get the IP (by ip addr or some way else?). Thx

tpppppub commented 5 months ago

Linux traffic control (tc) tool manages the traffic on a network interface. So you have to run the process inside a VM or docker container (which has virtual network interfaces) to use tc. Besides, using docker satisfies your demand of running benchmarks in one machine.

fionser commented 5 months ago

需要分清楚网卡接口 (eth0) 跟 IP 的区别。 只有一台机器就是限制 localloop 接口(lo) 还有就是区分好 同一个 IP 跟不同端口的区别。2pc.json 里面只设置了一个 IP (127.0.0.1)