网络之中充斥着林林总总的 DeepSeek 大模型本地部署教程,然而,鉴于其操作流程冗长繁杂,操作步骤繁多,且每一步均需人力干预,难以达成无人值守式部署,对于我们这些寻常之人而言,着实存在颇高的门槛。故而,历经对教程的深入研究以及多次亲身部署安装,特此输出一份自动化安装部署脚本,以利众人实现一键式安装部署。

1.1 DeepSeek 不同版本对系统基本要求
DeepSeek-V1系列参数规模:基础版本,支持1.5B-7B参数
系统要求:
CPU:4核以上
内存 ≥ 8GB(1.5B模型需4.2GB内存)
GPU:非必须,但CUDA支持可加速推理
存储:至少10GB磁盘空间
适用场景:基础代码生成、技术文档处理
DeepSeek-V2/V2.5系列参数规模:3B-13B参数(V2.5支持量化版本如3B-int4)
系统要求:
CPU:8核以上
内存 ≥ 16GB
GPU:推荐NVIDIA显卡(显存≥8GB),量化版显存占用约3-4GB
存储:20GB以上,需支持快速I/O
特性:优化数学能力(MATH-500基准达82.8%)、长文本处理
DeepSeek-V3系列参数规模:671亿参数(激活参数37亿)
系统要求:
CPU:16核以上
内存 ≥ 64GB
GPU:需NVIDIA A100/V100等专业卡(显存≥40GB)
存储:建议SSD ≥100GB
适用场景:大规模知识问答、复杂代码架构生成
DeepSeek-R1系列参数规模:1.5B-7B参数(专注推理优化)
系统要求:
CPU:4核
内存 ≥ 8GB(多线程优化)
GPU:可选,
显存 ≥ 6GB(支持多实例混合部署)
特性:高推理速度(CPU 实例达 3 tokens/s,GPU实例达15 tokens/s)
1.2 不同参数规模对系统基本要求
参数规模
CPU要求
GPU要求
存储要求
典型场景
部署建议
1.5B
4核 / ≥4GB内存
无需(或显存≥4GB)
≥10GB SSD
轻量级代码生成、教育辅导
适合入门级设备纯CPU部署
3B-int4
4核 / ≥8GB内存
显存≥6GB(量化优化)
≥15GB SSD
数学问题求解、智能客服
推荐8G显存设备混合部署
7B
8核 / ≥16GB内存
显存≥12GB(FP16精度)
≥20GB NVMe SSD
复杂文档分析、科研计算
需中高端显卡部署
13B
16核 / ≥32GB内存
显存≥24GB(非量化版)
≥50GB NVMe SSD
企业级智能决策、金融建模
需专业级计算卡部署
67B
32核 / ≥64GB内存
显存≥40GB(A100/V100)
≥100GB NVMe RAID
大规模知识问答、架构设计
需服务器级硬件部署
671亿参数
64核 / ≥256GB内存
显存≥80GB(多卡并行)
≥1TB NVMe RAID
国家级AI计算、超算中心
需分布式计算集群部署
2、准备烦请依照您的部署需求,参照第 1 章节所述的系统要求,选取恰当的版本以及参数规模。鉴于安装过程中需联网下载安装包,故而在安装部署进程中,务必要保持网络的畅通以及 Windows 系统的正常处理运行状态,以避免部署过程出现异常中止的情况。
本文中以是以(16G内存+8G显存)Windows系统为例进行安装部署的,结合CPU/GPU混合部署特性,支持并行运行多个模型实例。
3、自动化部署3.1 自动化部署脚本
创建自动化部署脚本文件在部署的机器的任意目录下创建一个后缀为.ps1的文件用于保存自动化部署脚本,文件命名您可自行命名。
本文是在C盘下新建了一个名为 deepseek 的文件夹,文件夹下创建一个名为 deploly_deepseek.ps1的文件保存自动化部署脚本。

将下面的脚本代码复制到您在第一步创建的后缀是 .ps1 文件中,本文是保存在deploly_deepseek.ps1中
不输出日志到文件版winget install --id Git.Git -ewinget install --id Python.Python.3.8 -e$ollamaUrl = "https://ollama.ai/download/OllamaSetup.exe" Invoke-WebRequest -Uri $ollamaUrl -OutFile "$env:TEMP\OllamaSetup.exe" Start-Process -Wait "$env:TEMP\OllamaSetup.exe" -ArgumentList "/S"git clone https://github.com/deepseek-ai/deepseek.git --branch multi-instancecd deepseekpython -m venv .venv.\.venv\Scripts\activatepip install -r requirements.txt --extra-index-url https://mirrors.aliyun.com/pypi/simple/ Start-Process powershell -ArgumentList "-Command python api.py --device cpu --port 8000 --model deepseek-r1-1.5b"Start-Process powershell -ArgumentList "-Command python api.py --device cuda --port 8001 --model deepseek-r1-3b-int4"ollama run deepseek-r1:1.5b --port 11434function Test-DeepSeekService($port, $deviceType) { $testPrompt = '{"prompt":"Hello, what is your name?"}' try { $response = Invoke-RestMethod -Uri "http://localhost:$port/generate" -Method Post -Body $testPrompt -ContentType "application/json" if ($response.result -match "DeepSeek") { Write-Host "√ $deviceType ($port) SUCCESS." } } catch { Write-Host "× $port FAILED: $_" }}Test-DeepSeekService -port 8000 -deviceType "CPU"Test-DeepSeekService -port 8001 -deviceType "GPU"Test-DeepSeekService -port 11434 -deviceType "Ollama"Get-Counter '\Process(*)\Working Set' | Where-Object {$_.InstanceName -match "python|ollama"}nvidia-smi --query-gpu=memory.used --format=csv输出日志到文件版$totalSteps = 12 $currentStep = 0 Write-Progress -Activity "env init" -Status "installing" -PercentComplete 0 try { $currentStep++ Write-Progress -Activity "install git" -Status "installing" -PercentComplete ($currentStep/$totalSteps*100) $gitLog = Start-Process -Wait -PassThru -FilePath "winget" -ArgumentList "install --id Git.Git -e" -RedirectStandardOutput "$PWD\git_install.log" -RedirectStandardError "$PWD\git_error.log" if ($gitLog.ExitCode -ne 0) { throw "Git install failed!" } $currentStep++ Write-Progress -Activity "install Python3.8" -Status "installing..." -PercentComplete ($currentStep/$totalSteps*100) $pythonLog = Start-Process -Wait -PassThru -FilePath "winget" -ArgumentList "install --id Python.Python.3.8 -e" -RedirectStandardOutput "$PWD\python_install.log" -RedirectStandardError "$PWD\python_error.log" if ($pythonLog.ExitCode -ne 0) { throw "Python install failed!" } $currentStep++ Write-Progress -Activity "download Ollama" -Status "0%" -PercentComplete ($currentStep/$totalSteps*100) $ollamaUrl = "https://ollama.ai/download/OllamaSetup.exe" $webClient = New-Object System.Net.WebClient $webClient.DownloadFileAsync([Uri]$ollamaUrl, "$env:TEMP\OllamaSetup.exe") while ($webClient.IsBusy) { $percent = [math]::Round(($webClient.BytesReceived/1MB)/(8/1MB)*100,2) Write-Progress -Activity "download Ollama" -Status "downloading $percent%" -PercentComplete $percent Start-Sleep -Milliseconds 100 } $currentStep++ Write-Progress -Activity "install Ollama" -Status "installing" -PercentComplete ($currentStep/$totalSteps*100) $installLog = Start-Process -Wait -PassThru -FilePath "$env:TEMP\OllamaSetup.exe" -ArgumentList "/S" -PassThru if ($installLog.ExitCode -ne 0) { throw "Ollama install failed!" }} catch { Write-Host "× stage 1 failed: $_" -ForegroundColor Red exit 1 }Write-Progress -Activity "model seting" -Status "init" -PercentComplete 25 try { $currentStep++ Write-Progress -Activity "clone model" -Status "cloning" -PercentComplete ($currentStep/$totalSteps*100) $gitOutput = & git clone https://github.com/deepseek-ai/deepseek.git --branch multi-instance 2>&1 | Tee-Object -FilePath "git_clone.log" if ($LASTEXITCODE -ne 0) { throw "clone failed!" } $currentStep++ Write-Progress -Activity "init venv" -Status "creating" -PercentComplete ($currentStep/$totalSteps*100) python -m venv .venv 2>&1 | Tee-Object -FilePath "venv_setup.log" $currentStep++ Write-Progress -Activity "install dependents" -Status "installing" -PercentComplete ($currentStep/$totalSteps*100) & .\.venv\Scripts\activate $pipOutput = & pip install -r requirements.txt --extra-index-url https://mirrors.aliyun.com/pypi/simple/ 2>&1 | Tee-Object -FilePath "pip_install.log" if ($LASTEXITCODE -ne 0) { throw "dependents install failed!" }} catch { Write-Host "× stage 2 failed: $_" -ForegroundColor Red exit 2 }Write-Progress -Activity "server deploy" -Status "starting" -PercentComplete 55 try { $currentStep++ Write-Progress -Activity "starting CPU service" -Status "8000" -PercentComplete ($currentStep/$totalSteps*100) $cpuProcess = Start-Process powershell -ArgumentList "-Command python api.py --device cpu --port 8000" -PassThru Start-Sleep -Seconds 2 if (-not $cpuProcess.HasExited) { Write-Host "√ CPU servcies started." } $currentStep++ Write-Progress -Activity "start GPU service" -Status "8001" -PercentComplete ($currentStep/$totalSteps*100) $gpuProcess = Start-Process powershell -ArgumentList "-Command python api.py --device cuda --port 8001" -PassThru $gpuMem = (nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) -as [int] if ($gpuMem -lt 3000) { throw "GPU service start failed!" } $currentStep++ Write-Progress -Activity "start Ollama" -Status "11434" -PercentComplete ($currentStep/$totalSteps*100) $ollamaJob = Start-Job -ScriptBlock { ollama run deepseek-r1:1.5b --port 11434 } Start-Sleep -Seconds 5 if (-not (Get-NetTCPConnection -LocalPort 11434 -ErrorAction SilentlyContinue)) { throw "Ollama started failed!" }} catch { Write-Host "× stage 3 failed: $_" -ForegroundColor Red exit 3 }Write-Progress -Activity "test service" -Status "testing" -PercentComplete 85 try { function Test-Service { param($port, $type) $retry = 3 while ($retry -gt 0) { try { $response = Invoke-RestMethod -Uri "http://localhost:$port/generate" -Method Post -Body '{"prompt":"test"}' -TimeoutSec 5 if ($response.result -match "DeepSeek") { Write-Host "√ $type ($port) PASS" return $true } } catch { Start-Sleep -Seconds 2 $retry-- } } return $false } $currentStep++ Write-Progress -Activity "CPU service" -Status "8000" -PercentComplete ($currentStep/$totalSteps*100) if (-not (Test-Service -port 8000 -type "CPU")) { throw "CPU service" } $currentStep++ Write-Progress -Activity "GPU service" -Status "8001" -PercentComplete ($currentStep/$totalSteps*100) if (-not (Test-Service -port 8001 -type "GPU")) { throw "GPU service" } $currentStep++ Write-Progress -Activity "Ollama" -Status "11434" -PercentComplete 100 if (-not (Test-Service -port 11434 -type "Ollama")) { throw "Ollama service" }} catch { Write-Host "× stage 4 failed: $_" -ForegroundColor Red exit 4 } Write-Host "`n SUCCESS" -ForegroundColor Green
脚本包含功能说明:
多级进度追踪 总进度条显示整体完成度(12个关键步骤)子进度条显示当前操作的实时状态(如下载百分比)颜色标记成功/失败状态(绿色√ / 红色×)错误处理机制 每个阶段独立异常捕获(try-catch块)关键操作退出码检查(winget/python安装)服务端口存活验证(Get-NetTCPConnection)日志记录功能 所有操作输出重定向到日志文件(git_install.log 等)使用Tee-Object同时显示控制台输出和记录日志错误日志单独保存(*_error.log )硬件状态监控 GPU显存占用实时检查(nvidia-smi)进程存活状态验证(HasExited属性)网络端口连通性测试修改安全策略,允许脚本运行检查当前执行策略打开 PowerShell 终端,输入命令查看当前策略状态:同时按住 windows + R 打开运行窗口后键入 powershell 打开 powershell 命令行窗口

若返回结果为Restricted,说明系统默认禁止运行脚本,需要修改执行策略,如果是其他状态,则不需要修改执行策略。

方法一(推荐):以管理员身份运行PowerShell,输入以下命令:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -ForceRemoteSigned 策略允许本地脚本运行,但要求远程下载的脚本需有数字签名,平衡安全性和实用性
-Scope CurrentUser表示仅修改当前用户的策略,无需管理员权限。
方法二(临时宽松策略):若需完全解除限制(慎用),可执行:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -ForceUnrestricted允许所有脚本运行,但存在安全风险

安全建议:完成操作后,建议恢复默认策略以降低风险:
Set-ExecutionPolicy Restricted -Scope CurrentUser -Force管理员权限:若修改全局策略(如LocalMachine),需以管理员身份运行PowerShell
推荐优先使用RemoteSigned策略保障安全性。
运行自动化部署脚本以管理员身份运行 powershell

执行窗口

执行日志


