Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
91ceb77
1
Parent(s):
49e617c
update
Browse files
setup.sh
CHANGED
@@ -5,71 +5,19 @@ pip install torch==2.2.0+cu121 torchvision==0.17.0+cu121 torchaudio==2.2.0+cu121
|
|
5 |
echo "Reinstalling NumPy with specific version..."
|
6 |
pip install --force-reinstall -v "numpy==1.25.2"
|
7 |
|
8 |
-
echo "Installing other requirements..."
|
9 |
-
pip install -r requirements.txt
|
10 |
-
|
11 |
-
# 创建延迟安装DISO的脚本
|
12 |
-
cat > install_diso.py << 'EOF'
|
13 |
-
import os
|
14 |
-
import subprocess
|
15 |
-
import torch
|
16 |
-
import time
|
17 |
-
|
18 |
-
# 等待GPU可用
|
19 |
-
def wait_for_gpu():
|
20 |
-
max_attempts = 30
|
21 |
-
for i in range(max_attempts):
|
22 |
-
try:
|
23 |
-
# 尝试导入spaces模块以初始化GPU
|
24 |
-
import spaces
|
25 |
-
if torch.cuda.is_available():
|
26 |
-
print(f"GPU可用: {torch.cuda.get_device_name(0)}")
|
27 |
-
return True
|
28 |
-
except:
|
29 |
-
pass
|
30 |
-
print(f"等待GPU可用... ({i+1}/{max_attempts})")
|
31 |
-
time.sleep(10)
|
32 |
-
return False
|
33 |
|
34 |
-
#
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
print("DISO安装完成")
|
44 |
|
45 |
-
if __name__ == "__main__":
|
46 |
-
if wait_for_gpu():
|
47 |
-
install_diso()
|
48 |
-
else:
|
49 |
-
print("GPU未能在指定时间内可用,无法安装DISO")
|
50 |
-
EOF
|
51 |
|
52 |
-
echo "
|
53 |
-
# 添加到app.py的启动脚本中运行安装脚本
|
54 |
-
mv app.py app_original.py
|
55 |
-
cat > app.py << 'EOF'
|
56 |
-
import os
|
57 |
-
import subprocess
|
58 |
-
import sys
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
if not os.path.exists(diso_installed_marker):
|
63 |
-
print("正在安装DISO包...")
|
64 |
-
try:
|
65 |
-
subprocess.run([sys.executable, "install_diso.py"])
|
66 |
-
with open(diso_installed_marker, "w") as f:
|
67 |
-
f.write("DISO installed")
|
68 |
-
except Exception as e:
|
69 |
-
print(f"DISO安装失败: {e}")
|
70 |
-
|
71 |
-
# 然后执行原始app.py的内容
|
72 |
-
exec(open("app_original.py").read())
|
73 |
-
EOF
|
74 |
-
|
75 |
-
echo "Setup completed successfully!"
|
|
|
5 |
echo "Reinstalling NumPy with specific version..."
|
6 |
pip install --force-reinstall -v "numpy==1.25.2"
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Compile and install DISO package
|
10 |
+
echo "Compiling and installing DISO..."
|
11 |
+
pip install ninja
|
12 |
+
mkdir -p diso_package
|
13 |
+
cd diso_package
|
14 |
+
git clone https://github.com/SarahWeiii/diso.git
|
15 |
+
cd diso
|
16 |
+
pip install -e .
|
17 |
+
cd ..
|
|
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
echo "Setup completed successfully!"
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
echo "Installing other requirements..."
|
23 |
+
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|