Spaces:
Running
on
Zero
Running
on
Zero
Update setup_blender.sh
Browse files- setup_blender.sh +13 -25
setup_blender.sh
CHANGED
@@ -20,12 +20,13 @@ UNIRIG_REPO_CLONE_DIR="${APP_DIR}/UniRig"
|
|
20 |
|
21 |
TORCH_VERSION="2.3.1"
|
22 |
TORCHVISION_VERSION="0.18.1"
|
23 |
-
|
|
|
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,18 +34,16 @@ export CPATH="${PYTHON_INCLUDE_DIR}:${CPATH}"
|
|
33 |
export C_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${C_INCLUDE_PATH}"
|
34 |
export CPLUS_INCLUDE_PATH="${PYTHON_INCLUDE_DIR}:${CPLUS_INCLUDE_PATH}"
|
35 |
|
36 |
-
#
|
37 |
# For ZeroGPU, common architectures are Ampere (8.0, 8.6) or Hopper (9.0).
|
38 |
-
|
39 |
-
# Using a common set for broader compatibility.
|
40 |
-
export TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0"
|
41 |
-
# Alternatively, for a more focused build if you know the target:
|
42 |
# export TORCH_CUDA_ARCH_LIST="8.6" # Example for A10G on ZeroGPU
|
43 |
|
44 |
echo "--- Setup Script Start ---"
|
45 |
echo "Target Blender Installation Directory: ${INSTALL_DIR}"
|
46 |
echo "Blender Python Executable: ${BLENDER_PY_EXEC}"
|
47 |
echo "Using CUDA_HOME=${CUDA_HOME}"
|
|
|
48 |
echo "TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST}"
|
49 |
echo "Initial PATH: ${PATH}"
|
50 |
echo "CPATH set to: ${CPATH}"
|
@@ -105,31 +104,20 @@ fi
|
|
105 |
echo "Upgrading pip for Blender Python..."
|
106 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --upgrade pip setuptools wheel -vvv
|
107 |
|
108 |
-
echo "Step 1: Installing PyTorch ${TORCH_VERSION} and Torchvision ${TORCHVISION_VERSION} for Blender's Python..."
|
109 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
|
110 |
torch==${TORCH_VERSION} \
|
111 |
torchvision==${TORCHVISION_VERSION} \
|
112 |
--index-url ${TORCH_INDEX_URL} -vvv
|
113 |
echo "PyTorch and Torchvision installation attempted."
|
114 |
|
115 |
-
#
|
116 |
-
|
117 |
-
# or specify version here e.g., flash-attn==<version>
|
118 |
-
# The TORCH_CUDA_ARCH_LIST environment variable set earlier will be used by its build process.
|
119 |
-
# Also ensure 'build-essential' is in your packages.txt for g++ compiler.
|
120 |
-
echo "Step 2: Installing flash-attn for Blender's Python..."
|
121 |
-
# Assuming flash-attn is in unirig_requirements.txt and will be picked up by the next step,
|
122 |
-
# OR if it needs to be a specific version not in the file, install it explicitly:
|
123 |
-
# "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir flash-attn -vvv
|
124 |
-
# For now, we'll rely on it being in unirig_requirements.txt and the env vars being set.
|
125 |
-
# If flash-attn continues to fail, you might need to install it explicitly here.
|
126 |
-
# The most robust way is to let it be installed by the requirements file if it's listed there
|
127 |
-
# with any specific version constraints UniRig might have. The environment variables should help.
|
128 |
|
129 |
echo "Step 3: Installing remaining dependencies from ${UNIRIG_REQS_FILE_IN_SPACE}..."
|
130 |
-
# This will install torch-scatter, torch-cluster, spconv, flash-attn (if listed), bpy, etc.
|
131 |
-
# flash-attn build
|
132 |
-
#
|
133 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE_IN_SPACE}" -vvv
|
134 |
|
135 |
echo "Dependency installation for Blender's Python complete."
|
|
|
20 |
|
21 |
TORCH_VERSION="2.3.1"
|
22 |
TORCHVISION_VERSION="0.18.1"
|
23 |
+
# ** MODIFIED: Changed to cu122 to align with common flash-attn pre-built wheels **
|
24 |
+
TARGET_CUDA_VERSION_SHORT="cu122"
|
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} # This might be nominal in ZeroGPU if nvcc isn't present
|
29 |
+
export PATH="${CUDA_HOME}/bin:${LOCAL_BIN_DIR}:${PATH}" # Add CUDA_HOME/bin to PATH
|
30 |
export MAX_JOBS=${MAX_JOBS:-4}
|
31 |
|
32 |
PYTHON_INCLUDE_DIR="/usr/include/python${BLENDER_PYTHON_VERSION#python}"
|
|
|
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}"
|
44 |
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}"
|
|
|
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} for Blender's Python..."
|
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 |
+
# Step 2 (flash-attn) is now implicitly handled by Step 3, relying on the correct PyTorch CUDA version.
|
115 |
+
echo "Step 2: (flash-attn will be installed via requirements file in the next step)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 build (if a wheel is not found) would use TORCH_CUDA_ARCH_LIST.
|
120 |
+
# Hopefully, a pre-built wheel for flash-attn (e.g., +pt23cu122) will be found due to PyTorch being cu122.
|
121 |
"${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE_IN_SPACE}" -vvv
|
122 |
|
123 |
echo "Dependency installation for Blender's Python complete."
|