#!/bin/bash
配置变量
container_prefix="gpuworker2-" #名称
base_ip="192.168.2."
start_ip=5 #创建节点最开始的ip地址
start_container=5
end_container=101 #创建节点结束的ip地址
network_name="my_macvlan_network"
volume_mount="/data/gpustack:/gpustack"
image_name="gpustack/gpustack"
server_url="http://192.168.2.3:80"
token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #为data下面的token
tools_url="https://gpustack-1303613262.cos.ap-guangzhou.myqcloud.com"
创建容器
for i in $(seq $start_container $end_container); do
计算IP地址和容器名称
container_name="{container_prefix}{i}"
container_ip="{base_ip}{i}"
echo "Creating container $container_name with IP $container_ip"
执行 Docker run 命令
docker run -v "volume_mount" -d --name "container_name" --gpus all \
--network="network_name" --ip "container_ip" \
"image_name" --worker-name "container_name" \
--server-url "server_url" --token "token" \
--tools-download-base-url "$tools_url"
sleep 5
检查是否成功
if [ $? -ne 0 ]; then
echo "Failed to create container $container_name"
fi
done