久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

首頁(yè)開(kāi)發(fā)教程Amazon EKS部署DeepSeek-R1模型教程

Amazon EKS部署DeepSeek-R1模型教程

2025-03-04 619

如果不想再為管理底層Kubernetes基礎(chǔ)架構(gòu)而費(fèi)神,可以選擇通過(guò)在Amazon EKS Auto Mode托管DeepSeek,以獲得更高的靈活性和可擴(kuò)展性。本文主要詳細(xì)介紹如何使用Amazon EKS托管DeepSeek-R1模型。

一、Amazon EKS介紹

Amazon EKS是高度可用、可擴(kuò)展且安全的Kubernetes服務(wù),主要用于在亞馬遜云科技AWS)上使用Kubernetes輕松部署、管理和擴(kuò)展容器化應(yīng)用程序。Amazon EKS跨多個(gè)亞馬遜云科技可用區(qū)運(yùn)行Kubernetes管理基礎(chǔ)設(shè)施,并自動(dòng)檢測(cè)和替換運(yùn)行狀況不佳的控制平面節(jié)點(diǎn),同時(shí)提供按需升級(jí)和修補(bǔ)。只需預(yù)置工作節(jié)點(diǎn)并將其連接到提供的Amazon EKS終端節(jié)點(diǎn)。

亞馬遜云科技官網(wǎng):點(diǎn)擊創(chuàng)建免費(fèi)賬戶

Amazon EKS部署DeepSeek-R1模型教程

本文將使用DeepSeek-R1-Distill-Llama-8B蒸餾模型,與擁有671B參數(shù)的完整DeepSeek-R1模型相比,對(duì)資源的需求更少,雖然功能相對(duì)較弱,但提供了一個(gè)更輕量級(jí)的選擇。如果希望部署完整的DeepSeek-R1模型,請(qǐng)?jiān)趘LLM配置中替換掉蒸餾模型。

二、安裝PreReqs

為簡(jiǎn)化設(shè)置流程,本文將使用Amazon CloudShell。

Amazon EKS部署DeepSeek-R1模型教程

# Installing kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Install Terraform
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform

三、使用Terraform創(chuàng)建啟用Auto Mode的Amazon EKS集群

使用Terraform輕松配置基礎(chǔ)架構(gòu),包括Amazon VPC、Amazon ECR存儲(chǔ)庫(kù)以及啟用Auto Mode的Amazon EKS集群。

# Clone the GitHub repo with the manifests
git clone -b v0.1 https://github.com/aws-samples/deepseek-using-vllm-on-eks
cd deepseek-using-vllm-on-eks
# Apply the Terraform configuration
terraform init
terraform apply -auto-approve
# After Terraform finishes, configure kubectl with the new EKS cluster
$(terraform output configure_kubectl | jq -r)

四、創(chuàng)建Amazon EKS Auto Mode NodePool

創(chuàng)建一個(gè)自定義NodePool,用來(lái)支持GPU。

# Create a custom NodePool with GPU support
kubectl apply -f manifests/gpu-nodepool.yaml
# Check if the NodePool is in 'Ready' state
kubectl get nodepool/gpu-nodepool

五、部署DeepSeek模型

為簡(jiǎn)化使用vLLM部署DeepSeek-R1-Distill-Llama-8B模型的過(guò)程,本演示提供了一個(gè)sed命令,可以設(shè)置模型名稱和參數(shù)。

# Use the sed command to replace the placeholder with the model name and configuration parameters
sed -i "s|__MODEL_NAME_AND_PARAMETERS__|deepseek-ai/DeepSeek-R1-Distill-Llama-8B --max_model 2048|g" manifests/deepseek-deployment-gpu.yaml
# Deploy the DeepSeek model on Kubernetes
kubectl apply -f manifests/deepseek-deployment-gpu.yaml
# Check the pods in the 'deepseek' namespace 
kubectl get po -n deepseek

起初,在Amazon EKS Auto Mode為底層EC2實(shí)例配置所需的GPU驅(qū)動(dòng)程序時(shí),pod可能會(huì)處于Pending(待處理)狀態(tài)。

如果pod在Pending(待處理)狀態(tài)停留了幾分鐘,請(qǐng)確認(rèn)亞馬遜云科技賬戶有足夠的服務(wù)配額來(lái)啟動(dòng)所需的實(shí)例,需要檢查G或P實(shí)例的配額限制情況。

注意:這些配額基于vCPU,而非實(shí)例數(shù)量,因此請(qǐng)務(wù)必按要求申請(qǐng)配額。

# Wait for the pod to reach the 'Running' state
watch -n 1 kubectl get po -n deepseek
# Verify that a new Node has been created
kubectl get nodes -l owner=data-engineer
# Check the logs to confirm that vLLM has started
kubectl logs deployment.apps/deepseek-deployment -n deepseek

部署準(zhǔn)備就緒后,日志條目將顯示“應(yīng)用程序啟動(dòng)完成”。

六、與DeepSeek LLM交互

接下來(lái),創(chuàng)建一個(gè)本地代理,使用curl請(qǐng)求與模型進(jìn)行交互。

# Set up a proxy to forward the service port to your local terminal
kubectl port-forward svc/deepseek-svc -n deepseek 8080:80 > port-forward.log 2>&1 &
# Send a curl request to the model
curl -X POST "http://localhost:8080/v1/chat/completions" -H "Content-Type: application/json" --data '{
"model": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B",
"messages": [
{
"role": "user",
"content": "What is Kubernetes?"
}
]
}'

根據(jù)模型輸出的復(fù)雜程度,響應(yīng)可能需要幾秒鐘時(shí)間,可以通過(guò)deepseek-deployment日志監(jiān)控進(jìn)度。

七、為模型構(gòu)建聊天機(jī)器人UI界面

直接使用API請(qǐng)求可以正常工作,但也可以構(gòu)建一個(gè)更友好的聊天機(jī)器人UI界面來(lái)與模型交互,該界面的源代碼已在GitHub中提供。

# Retrieve the ECR repository URI created by Terraform
export ECR_REPO=$(terraform output ecr_repository_uri | jq -r)
# Build the container image for the Chatbot UI
docker build -t $ECR_REPO:0.1 chatbot-ui/application/.
# Login to ECR and push the image
aws ecr get-login-password | docker login --username AWS --password-stdin $ECR_REPO
docker push $ECR_REPO:0.1
# Update the deployment manifest to use the image
sed -i "s#__IMAGE_DEEPSEEK_CHATBOT__#$ECR_REPO:0.1#g" chatbot-ui/manifests/deployment.yaml
# Generate a random password for the Chatbot UI login
sed -i "s|__PASSWORD__|$(openssl rand -base64 12 | tr -dc A-Za-z0-9 | head -c 16)|" chatbot-ui/manifests/deployment.yaml
# Deploy the UI and create the ingress class required for load balancers
kubectl apply -f chatbot-ui/manifests/ingress-class.yaml
kubectl apply -f chatbot-ui/manifests/deployment.yaml
# Get the URL for the load balancer to access the application
echo http://$(kubectl get ingress/deepseek-chatbot-ingress -n deepseek -o json | jq -r '.status.loadBalancer.ingress[0].hostname')

等待幾秒鐘,以便負(fù)載均衡器完成配置。

要訪問(wèn)聊天機(jī)器人UI界面,需要使用存儲(chǔ)在Kubernetes密鑰中的用戶名和密碼。

echo -e "Username=$(kubectl get secret deepseek-chatbot-secrets -n deepseek -o jsonpath='{.data.admin-username}' | base64 --decode)\nPassword=$(kubectl get secret deepseek-chatbot-secrets -n deepseek -o jsonpath='{.data.admin-password}' | base64 --decode)"

登錄后,界面將顯示一個(gè)新的“聊天機(jī)器人”選項(xiàng)卡,可以在其中與模型進(jìn)行交互。

Amazon EKS部署DeepSeek-R1模型教程

按照上述步驟,可以在Amazon EKS上高效部署DeepSeek-R1模型,并利用Amazon EKS靈活的擴(kuò)展選項(xiàng)和精細(xì)的資源控制,在保持高性能的同時(shí)優(yōu)化成本。該解決方案利用了Kubernetes的原生功能和Amazon EKS Auto Mode等特性,提供了一個(gè)高度可配置的部署方案,可以精確滿足運(yùn)營(yíng)需求和預(yù)算范圍。

相關(guān)推薦:《亞馬遜云科技Amazon EC2部署DeepSeek-R1蒸餾模型教程

  • 廣告合作

  • QQ群號(hào):4114653

溫馨提示:
1、本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享網(wǎng)絡(luò)內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。郵箱:2942802716#qq.com(#改為@)。 2、本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)裁,轉(zhuǎn)載請(qǐng)注明出處“站長(zhǎng)百科”和原文地址。

相關(guān)文章