ShopTRAINING/install_dependencies.sh

43 lines
1.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "药店销售预测系统 - 依赖库安装脚本"
echo "=================================="
echo ""
echo "请选择要安装的版本:"
echo "1. CPU版本适用于没有NVIDIA GPU的计算机"
echo "2. GPU版本 - CUDA 12.8适用于最新的NVIDIA GPU"
echo "3. GPU版本 - CUDA 11.8适用于较旧的NVIDIA GPU"
echo ""
read -p "请输入选项 (1/2/3): " choice
if [ "$choice" = "1" ]; then
echo "正在安装CPU版本依赖..."
pip install -r requirements.txt
elif [ "$choice" = "2" ]; then
echo "正在安装GPU版本(CUDA 12.1)依赖..."
echo "首先安装基础依赖..."
pip install -r requirements-gpu.txt --no-deps
echo "安装除PyTorch以外的其他依赖..."
pip install numpy==2.3.0 pandas==2.3.0 matplotlib==3.10.3 scikit-learn==1.7.0 tqdm==4.67.1 openpyxl==3.1.5
echo "从PyTorch官方源安装CUDA 12.1版本的PyTorch..."
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
elif [ "$choice" = "3" ]; then
echo "正在安装GPU版本(CUDA 11.8)依赖..."
echo "首先安装基础依赖..."
pip install -r requirements-gpu-cu118.txt --no-deps
echo "安装除PyTorch以外的其他依赖..."
pip install numpy==2.3.0 pandas==2.3.0 matplotlib==3.10.3 scikit-learn==1.7.0 tqdm==4.67.1 openpyxl==3.1.5
echo "从PyTorch官方源安装CUDA 11.8版本的PyTorch..."
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
else
echo "无效的选项!请重新运行脚本并选择正确的选项。"
exit 1
fi
echo ""
echo "依赖库安装完成!"
echo ""
echo "验证PyTorch GPU支持状态..."
python -c "import torch; print('CUDA是否可用:', torch.cuda.is_available()); print('PyTorch版本:', torch.__version__); print('GPU数量:', torch.cuda.device_count()); print('GPU名称:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else '无GPU')"