d1111111 commited on
Commit
6df2efe
·
verified ·
1 Parent(s): e9ebfac

Upload 2 files

Browse files
Files changed (2) hide show
  1. install.bash +80 -0
  2. run.bash +9 -0
install.bash ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Bash strict mode
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+
6
+ # 设置镜像源与临时目录
7
+ export HF_ENDPOINT="https://hf-mirror.com"
8
+
9
+
10
+ # 获取当前脚本绝对路径
11
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ export TMPDIR="${script_dir}/linshi"
13
+
14
+
15
+ create_venv=true
16
+ # 函数:退出脚本并打印错误信息
17
+ function exit_with_error {
18
+ echo "错误:$1"
19
+ exit 1
20
+ }
21
+
22
+ # 解析命令行参数
23
+ while [[ $# -gt 0 ]]; do
24
+ case "$1" in
25
+ --disable-venv)
26
+ create_venv=false
27
+ shift
28
+ ;;
29
+ *)
30
+ exit_with_error "未知参数:$1"
31
+ ;;
32
+ esac
33
+ done
34
+
35
+ # 函数:创建并激活Python虚拟环境
36
+ function create_and_activate_venv {
37
+ if ! command -v python3 &>/dev/null; then
38
+ exit_with_error "未找到Python3,请确保已安装。"
39
+ fi
40
+
41
+ if [ ! -d "venv" ]; then
42
+ echo "创建 Python 虚拟环境..."
43
+ python3 -m venv venv || exit_with_error "创建虚拟环境失败"
44
+ fi
45
+
46
+ source "$script_dir/venv/bin/activate" || exit_with_error "激活虚拟环境失败."
47
+ }
48
+
49
+ # 创建并激活Python虚拟环境
50
+ if $create_venv; then
51
+ create_and_activate_venv
52
+ fi
53
+
54
+ cd "$script_dir" || print_error_and_exit "无法进入脚本目录:$script_dir"
55
+
56
+ # 显示安装进度
57
+ echo "开始安装依赖项..."
58
+ pip install torch==2.2.2+cu121 torchvision==0.17.2+cu121
59
+ pip install xformers==0.0.25.post1
60
+
61
+
62
+ echo "更新并安装系统依赖..."
63
+ sudo apt-get update -qq || print_error_and_exit "更新软件包列表失败"
64
+ sudo apt-get install -y sudo -qq || print_error_and_exit "安装 sudo 失败"
65
+
66
+ echo "设置时区为中国上海..."
67
+ TZ=Asia/Shanghai
68
+ ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && apt update && apt install -y python3-tk || exit_with_error "设置时区失败."
69
+
70
+ # 安装其他Python依赖
71
+ cd "$script_dir" || print_error_and_exit "无法进入脚本目录:$script_dir"
72
+
73
+ pip install -r requirements_versions.txt || exit_with_error "安装 requirements.txt 失败."
74
+
75
+ echo "安装pickleshare..."
76
+ pip install pickleshare -q || print_error_and_exit "安装 pickleshare 失败"
77
+
78
+ echo -e "\n所有依赖安装成功,现在您可以执行下一步操作。\n"
79
+
80
+ exit 0
run.bash ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ export HF_HOME=huggingface
3
+ export PYTHONUTF8=1
4
+ # 获取脚本所在目录的绝对路径
5
+ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
6
+ # 激活虚拟环境
7
+ source "$script_dir/venv/bin/activate"
8
+ cd "$script_dir"
9
+ HF_ENDPOINT=https://hf-mirror.com python launch.py "$@"