57 lines
1.3 KiB
Bash
57 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# 变量
|
|
#
|
|
# home
|
|
# user
|
|
# passwd
|
|
#
|
|
# 开始要检查安装nvidia驱动
|
|
|
|
create_user()
|
|
{
|
|
}
|
|
sudo apt install git-lfs
|
|
sudo rm -rf {{home}}
|
|
sudo mkdir {{home}}
|
|
sudo chown -R $(id -un):$(id -gn) {{home}}
|
|
sudo apt -y install python3-venv
|
|
mkdir {{home}}/.pip
|
|
cat <<EOF> {{home}}/.pip/pip.conf
|
|
[global]
|
|
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
|
|
[install]
|
|
trusted-host = https://pypi.tuna.tsinghua.edu.cn
|
|
EOF
|
|
cat <<EOF>{{home}}/run.sh
|
|
#!/bin/bash
|
|
|
|
~/py3/bin/python -m vllm.entrypoints.openai.api_server --model ./QwQ-32B --served-model-name qwq:
|
|
32b --gpu-memory-utilization 0.9 --max_model_len 40960 --tensor-parallel-size 4
|
|
EOF
|
|
chmod +x {{home}}/run.sh
|
|
cat <<EOF>{{user}}.service
|
|
[Unit]
|
|
Wants=systemd-networkd.service
|
|
Requires=nginx.service
|
|
|
|
[Service]
|
|
Type=forking
|
|
ExecStart=su - {{user}} -c "{{home}}/run.sh"
|
|
ExecStop=su - {{user}} "killname vllm"
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
sudo cp {{user}}.service /etc/systemd/system
|
|
python3 -m venv {{home}}/py3
|
|
{{home}}/py3/bin/pip install vllm
|
|
sudo deluser {{user}}
|
|
sudo delgroup {{user}}
|
|
sudo groupadd {{user}}
|
|
sudo useradd -m -g {{user}} -s /usr/bin/bash -d {{home}} {{user}}
|
|
echo "{{user}}:{{passwd}}" | sudo chpasswd
|
|
sudo chown -R {{user}}:{{user}} {{home}}
|
|
systemctl enable {{user}}.service
|
|
systemctl start {{user}}.service
|
|
|
|
exit 0
|