Spaces:
Running
on
Zero
Running
on
Zero
Update setup_blender.sh
Browse files- setup_blender.sh +15 -29
setup_blender.sh
CHANGED
@@ -20,13 +20,12 @@ UNIRIG_REPO_CLONE_DIR="${APP_DIR}/UniRig"
|
|
20 |
|
21 |
TORCH_VERSION="2.3.1"
|
22 |
TORCHVISION_VERSION="0.18.1"
|
23 |
-
|
24 |
-
TARGET_CUDA_VERSION_SHORT="cu121"
|
25 |
TORCH_INDEX_URL="https://download.pytorch.org/whl/${TARGET_CUDA_VERSION_SHORT}"
|
26 |
|
27 |
# --- Set Environment Variables for Build ---
|
28 |
-
export CUDA_HOME=${CUDA_HOME:-/usr/local/cuda}
|
29 |
-
export PATH="${CUDA_HOME}/bin:${LOCAL_BIN_DIR}:${PATH}"
|
30 |
export MAX_JOBS=${MAX_JOBS:-4}
|
31 |
|
32 |
PYTHON_INCLUDE_DIR="/usr/include/python${BLENDER_PYTHON_VERSION#python}"
|
@@ -34,10 +33,7 @@ export CPATH="${PYTHON_INCLUDE_DIR}:${CPATH}"
|
|
34 |
export C_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${C_INCLUDE_PATH}"
|
35 |
export CPLUS_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${CPLUS_INCLUDE_PATH}"
|
36 |
|
37 |
-
# Specify CUDA Architectures for compilation (e.g. flash-attn if it still tries to build parts)
|
38 |
-
# For ZeroGPU, common architectures are Ampere (8.0, 8.6) or Hopper (9.0).
|
39 |
export TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0" # General set for compatibility
|
40 |
-
# export TORCH_CUDA_ARCH_LIST="8.6" # Example for A10G on ZeroGPU
|
41 |
|
42 |
echo "--- Setup Script Start ---"
|
43 |
echo "Target Blender Installation Directory: ${INSTALL_DIR}"
|
@@ -45,15 +41,6 @@ echo "Blender Python Executable: ${BLENDER_PY_EXEC}"
|
|
45 |
echo "Using CUDA_HOME=${CUDA_HOME}"
|
46 |
echo "Targeting PyTorch for CUDA: ${TARGET_CUDA_VERSION_SHORT}"
|
47 |
echo "TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST}"
|
48 |
-
echo "Initial PATH: ${PATH}"
|
49 |
-
echo "CPATH set to: ${CPATH}"
|
50 |
-
echo "Expected Python include directory: ${PYTHON_INCLUDE_DIR}"
|
51 |
-
|
52 |
-
if [ -f "${PYTHON_INCLUDE_DIR}/Python.h" ]; then
|
53 |
-
echo "Found Python.h at ${PYTHON_INCLUDE_DIR}/Python.h"
|
54 |
-
else
|
55 |
-
echo "WARNING: Python.h NOT FOUND at ${PYTHON_INCLUDE_DIR}/Python.h. Ensure python${BLENDER_PYTHON_VERSION#python}-dev is in packages.txt and installed."
|
56 |
-
fi
|
57 |
|
58 |
# --- Download and Extract Blender ---
|
59 |
mkdir -p "${BLENDER_INSTALL_BASE}"
|
@@ -73,7 +60,7 @@ if [ ! -d "${INSTALL_DIR}" ] || [ -z "$(ls -A "${INSTALL_DIR}")" ]; then
|
|
73 |
if [ -d "${INSTALL_DIR}" ]; then
|
74 |
echo "Blender extracted successfully to ${INSTALL_DIR}"
|
75 |
else
|
76 |
-
echo "ERROR: Blender extraction failed
|
77 |
ls -la "${BLENDER_INSTALL_BASE}"
|
78 |
exit 1
|
79 |
fi
|
@@ -87,7 +74,7 @@ if [ -f "${INSTALL_DIR}/blender" ]; then
|
|
87 |
ln -sf "${INSTALL_DIR}/blender" "${LOCAL_BIN_DIR}/blender"
|
88 |
echo "Local symlink created at ${LOCAL_BIN_DIR}/blender."
|
89 |
else
|
90 |
-
echo "WARNING: Blender executable not found at ${INSTALL_DIR}/blender.
|
91 |
fi
|
92 |
|
93 |
# --- Install Dependencies into Blender's Python ---
|
@@ -104,21 +91,20 @@ fi
|
|
104 |
echo "Upgrading pip for Blender Python..."
|
105 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --upgrade pip setuptools wheel -vvv
|
106 |
|
107 |
-
echo "Step 1: Installing PyTorch ${TORCH_VERSION} (for CUDA ${TARGET_CUDA_VERSION_SHORT}) and Torchvision ${TORCHVISION_VERSION}
|
108 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
|
109 |
torch==${TORCH_VERSION} \
|
110 |
torchvision==${TORCHVISION_VERSION} \
|
111 |
--index-url ${TORCH_INDEX_URL} -vvv
|
112 |
echo "PyTorch and Torchvision installation attempted."
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
echo "Step 3: Installing remaining dependencies from ${UNIRIG_REQS_FILE_IN_SPACE}..."
|
118 |
# This will install torch-scatter, torch-cluster, spconv, flash-attn (if listed and compatible wheel found), bpy, etc.
|
119 |
-
# flash-attn
|
120 |
-
|
121 |
-
|
|
|
122 |
|
123 |
echo "Dependency installation for Blender's Python complete."
|
124 |
|
@@ -127,14 +113,14 @@ UNIRIG_SRC_DIR="${UNIRIG_REPO_CLONE_DIR}/src"
|
|
127 |
INIT_PY_PATH="${UNIRIG_SRC_DIR}/__init__.py"
|
128 |
if [ -d "${UNIRIG_SRC_DIR}" ]; then
|
129 |
if [ ! -f "${INIT_PY_PATH}" ]; then
|
130 |
-
echo "Creating missing __init__.py in ${UNIRIG_SRC_DIR}
|
131 |
touch "${INIT_PY_PATH}"
|
132 |
echo "__init__.py created."
|
133 |
else
|
134 |
echo "${INIT_PY_PATH} already exists."
|
135 |
fi
|
136 |
else
|
137 |
-
echo "WARNING: UniRig src directory not found at ${UNIRIG_SRC_DIR}.
|
138 |
fi
|
139 |
|
140 |
# (Optional) VRM Addon installation
|
@@ -146,7 +132,7 @@ if [ -f "${ABSOLUTE_ADDON_PATH}" ]; then
|
|
146 |
"${BLENDER_PY_EXEC}" -c "import bpy, os; bpy.ops.preferences.addon_install(overwrite=True, filepath=os.path.abspath('${VRM_ADDON_REL_PATH}')); bpy.ops.preferences.addon_enable(module='io_scene_vrm'); print('VRM Addon installed and enabled.')")
|
147 |
echo "VRM addon installation attempted."
|
148 |
else
|
149 |
-
echo "VRM addon zip not found at ${ABSOLUTE_ADDON_PATH}, skipping
|
150 |
fi
|
151 |
|
152 |
# --- Cleanup ---
|
|
|
20 |
|
21 |
TORCH_VERSION="2.3.1"
|
22 |
TORCHVISION_VERSION="0.18.1"
|
23 |
+
TARGET_CUDA_VERSION_SHORT="cu121" # PyTorch 2.3.1 wheels are available for cu121
|
|
|
24 |
TORCH_INDEX_URL="https://download.pytorch.org/whl/${TARGET_CUDA_VERSION_SHORT}"
|
25 |
|
26 |
# --- Set Environment Variables for Build ---
|
27 |
+
export CUDA_HOME=${CUDA_HOME:-/usr/local/cuda}
|
28 |
+
export PATH="${CUDA_HOME}/bin:${LOCAL_BIN_DIR}:${PATH}"
|
29 |
export MAX_JOBS=${MAX_JOBS:-4}
|
30 |
|
31 |
PYTHON_INCLUDE_DIR="/usr/include/python${BLENDER_PYTHON_VERSION#python}"
|
|
|
33 |
export C_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${C_INCLUDE_PATH}"
|
34 |
export CPLUS_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${CPLUS_INCLUDE_PATH}"
|
35 |
|
|
|
|
|
36 |
export TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0" # General set for compatibility
|
|
|
37 |
|
38 |
echo "--- Setup Script Start ---"
|
39 |
echo "Target Blender Installation Directory: ${INSTALL_DIR}"
|
|
|
41 |
echo "Using CUDA_HOME=${CUDA_HOME}"
|
42 |
echo "Targeting PyTorch for CUDA: ${TARGET_CUDA_VERSION_SHORT}"
|
43 |
echo "TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# --- Download and Extract Blender ---
|
46 |
mkdir -p "${BLENDER_INSTALL_BASE}"
|
|
|
60 |
if [ -d "${INSTALL_DIR}" ]; then
|
61 |
echo "Blender extracted successfully to ${INSTALL_DIR}"
|
62 |
else
|
63 |
+
echo "ERROR: Blender extraction failed. Expected: ${INSTALL_DIR}"
|
64 |
ls -la "${BLENDER_INSTALL_BASE}"
|
65 |
exit 1
|
66 |
fi
|
|
|
74 |
ln -sf "${INSTALL_DIR}/blender" "${LOCAL_BIN_DIR}/blender"
|
75 |
echo "Local symlink created at ${LOCAL_BIN_DIR}/blender."
|
76 |
else
|
77 |
+
echo "WARNING: Blender executable not found at ${INSTALL_DIR}/blender."
|
78 |
fi
|
79 |
|
80 |
# --- Install Dependencies into Blender's Python ---
|
|
|
91 |
echo "Upgrading pip for Blender Python..."
|
92 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --upgrade pip setuptools wheel -vvv
|
93 |
|
94 |
+
echo "Step 1: Installing PyTorch ${TORCH_VERSION} (for CUDA ${TARGET_CUDA_VERSION_SHORT}) and Torchvision ${TORCHVISION_VERSION}..."
|
95 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
|
96 |
torch==${TORCH_VERSION} \
|
97 |
torchvision==${TORCHVISION_VERSION} \
|
98 |
--index-url ${TORCH_INDEX_URL} -vvv
|
99 |
echo "PyTorch and Torchvision installation attempted."
|
100 |
|
101 |
+
echo "Step 2: Installing remaining dependencies from ${UNIRIG_REQS_FILE_IN_SPACE}..."
|
102 |
+
# ** MODIFIED: Added --only-binary flash-attn to prevent source builds for flash-attn **
|
|
|
|
|
103 |
# This will install torch-scatter, torch-cluster, spconv, flash-attn (if listed and compatible wheel found), bpy, etc.
|
104 |
+
# Ensure 'flash-attn==2.5.9.post1' (or similar compatible version) is in unirig_requirements.txt
|
105 |
+
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
|
106 |
+
--only-binary flash-attn \
|
107 |
+
-r "${UNIRIG_REQS_FILE_IN_SPACE}" -vvv
|
108 |
|
109 |
echo "Dependency installation for Blender's Python complete."
|
110 |
|
|
|
113 |
INIT_PY_PATH="${UNIRIG_SRC_DIR}/__init__.py"
|
114 |
if [ -d "${UNIRIG_SRC_DIR}" ]; then
|
115 |
if [ ! -f "${INIT_PY_PATH}" ]; then
|
116 |
+
echo "Creating missing __init__.py in ${UNIRIG_SRC_DIR}..."
|
117 |
touch "${INIT_PY_PATH}"
|
118 |
echo "__init__.py created."
|
119 |
else
|
120 |
echo "${INIT_PY_PATH} already exists."
|
121 |
fi
|
122 |
else
|
123 |
+
echo "WARNING: UniRig src directory not found at ${UNIRIG_SRC_DIR}."
|
124 |
fi
|
125 |
|
126 |
# (Optional) VRM Addon installation
|
|
|
132 |
"${BLENDER_PY_EXEC}" -c "import bpy, os; bpy.ops.preferences.addon_install(overwrite=True, filepath=os.path.abspath('${VRM_ADDON_REL_PATH}')); bpy.ops.preferences.addon_enable(module='io_scene_vrm'); print('VRM Addon installed and enabled.')")
|
133 |
echo "VRM addon installation attempted."
|
134 |
else
|
135 |
+
echo "VRM addon zip not found at ${ABSOLUTE_ADDON_PATH}, skipping."
|
136 |
fi
|
137 |
|
138 |
# --- Cleanup ---
|