jkorstad commited on
Commit
9bd541c
·
verified ·
1 Parent(s): ac9b0a5

Update setup_blender.sh

Browse files
Files changed (1) hide show
  1. setup_blender.sh +23 -12
setup_blender.sh CHANGED
@@ -20,13 +20,13 @@ BLENDER_PY_EXEC="${INSTALL_DIR}/${BLENDER_MAJOR_MINOR}/python/bin/${BLENDER_PYTH
20
  UNIRIG_REQS_FILE_IN_SPACE="${APP_DIR}/unirig_requirements.txt"
21
  UNIRIG_REPO_CLONE_DIR="${APP_DIR}/UniRig"
22
 
 
23
  TORCH_VERSION="2.3.1"
24
- # TORCHVISION_VERSION="0.18.1" # Already in unirig_requirements.txt
25
- # NUMPY_VERSION="1.26.4" # Already in unirig_requirements.txt
26
- TARGET_CUDA_VERSION_SHORT="cu121"
27
  TORCH_INDEX_URL="https://download.pytorch.org/whl/${TARGET_CUDA_VERSION_SHORT}"
28
- PYG_FIND_LINKS_URL="https://data.pyg.org/whl/torch-${TORCH_VERSION}+${TARGET_CUDA_VERSION_SHORT}.html"
29
- # SPCONV_PACKAGE="spconv-${TARGET_CUDA_VERSION_SHORT}" # Already in unirig_requirements.txt
30
 
31
  # --- Set Environment Variables for Build ---
32
  export CUDA_HOME=${CUDA_HOME:-/usr/local/cuda} # Keep for system CUDA if needed by compilations
@@ -57,7 +57,10 @@ fi
57
  mkdir -p "${BLENDER_INSTALL_BASE}"
58
  mkdir -p "${LOCAL_BIN_DIR}" # Ensure local_bin exists
59
 
60
- if [ ! -d "${INSTALL_DIR}/blender-${BLENDER_VERSION}-linux-x64" ]; then # Check if specific version is already extracted
 
 
 
61
  echo "Downloading Blender ${BLENDER_VERSION}..."
62
  if [ ! -f "/tmp/${BLENDER_TARBALL}" ]; then
63
  wget -nv -O "/tmp/${BLENDER_TARBALL}" ${BLENDER_URL}
@@ -83,9 +86,6 @@ fi
83
  echo "Extraction complete."
84
 
85
  # --- Create Blender Symlink (Optional - to local_bin) ---
86
- # This system symlink would require sudo and likely fail:
87
- # ln -sf ${INSTALL_DIR}/blender /usr/local/bin/blender
88
- # Instead, create a local symlink if desired, and ensure local_bin is in PATH (done above)
89
  if [ -f "${INSTALL_DIR}/blender" ]; then
90
  echo "Creating local symlink for Blender executable in ${LOCAL_BIN_DIR}..."
91
  ln -sf "${INSTALL_DIR}/blender" "${LOCAL_BIN_DIR}/blender"
@@ -110,9 +110,20 @@ fi
110
  echo "Upgrading pip for Blender Python..."
111
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --upgrade pip setuptools wheel -vvv
112
 
113
- # Simplified: Install all from unirig_requirements.txt
114
- # Ensure unirig_requirements.txt has all specific versions and index URLs for torch, pyg, spconv, etc.
115
- echo "Installing all dependencies from ${UNIRIG_REQS_FILE_IN_SPACE}..."
 
 
 
 
 
 
 
 
 
 
 
116
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE_IN_SPACE}" -vvv
117
 
118
  echo "Dependency installation for Blender's Python complete."
 
20
  UNIRIG_REQS_FILE_IN_SPACE="${APP_DIR}/unirig_requirements.txt"
21
  UNIRIG_REPO_CLONE_DIR="${APP_DIR}/UniRig"
22
 
23
+ # PyTorch specific versions and URLs for pre-installation
24
  TORCH_VERSION="2.3.1"
25
+ TORCHVISION_VERSION="0.18.1"
26
+ TARGET_CUDA_VERSION_SHORT="cu121" # Ensure this matches ZeroGPU environment
 
27
  TORCH_INDEX_URL="https://download.pytorch.org/whl/${TARGET_CUDA_VERSION_SHORT}"
28
+ # PYG_FIND_LINKS_URL is used when installing from requirements.txt later
29
+ # PYG_FIND_LINKS_URL="https://data.pyg.org/whl/torch-${TORCH_VERSION}+${TARGET_CUDA_VERSION_SHORT}.html"
30
 
31
  # --- Set Environment Variables for Build ---
32
  export CUDA_HOME=${CUDA_HOME:-/usr/local/cuda} # Keep for system CUDA if needed by compilations
 
57
  mkdir -p "${BLENDER_INSTALL_BASE}"
58
  mkdir -p "${LOCAL_BIN_DIR}" # Ensure local_bin exists
59
 
60
+ # Check if the *specific version's directory* inside INSTALL_DIR exists and is not empty.
61
+ # Blender extracts to a folder like "blender-4.2.0-linux-x64"
62
+ if [ ! -d "${INSTALL_DIR}" ] || [ -z "$(ls -A "${INSTALL_DIR}")" ]; then
63
+ echo "Blender not found or directory empty at ${INSTALL_DIR}. Proceeding with download and extraction."
64
  echo "Downloading Blender ${BLENDER_VERSION}..."
65
  if [ ! -f "/tmp/${BLENDER_TARBALL}" ]; then
66
  wget -nv -O "/tmp/${BLENDER_TARBALL}" ${BLENDER_URL}
 
86
  echo "Extraction complete."
87
 
88
  # --- Create Blender Symlink (Optional - to local_bin) ---
 
 
 
89
  if [ -f "${INSTALL_DIR}/blender" ]; then
90
  echo "Creating local symlink for Blender executable in ${LOCAL_BIN_DIR}..."
91
  ln -sf "${INSTALL_DIR}/blender" "${LOCAL_BIN_DIR}/blender"
 
110
  echo "Upgrading pip for Blender Python..."
111
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --upgrade pip setuptools wheel -vvv
112
 
113
+ echo "Step 1: Installing PyTorch ${TORCH_VERSION} and Torchvision ${TORCHVISION_VERSION} for Blender's Python..."
114
+ # Install torch and torchvision first, as other packages (torch-scatter, etc.) depend on it being present for their setup.
115
+ # Ensure your unirig_requirements.txt also lists these versions so pip can resolve correctly later if needed,
116
+ # but this direct install ensures they are present for build steps of other packages.
117
+ "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
118
+ torch==${TORCH_VERSION} \
119
+ torchvision==${TORCHVISION_VERSION} \
120
+ --index-url ${TORCH_INDEX_URL} -vvv
121
+ echo "PyTorch and Torchvision installation attempted."
122
+
123
+ echo "Step 2: Installing remaining dependencies from ${UNIRIG_REQS_FILE_IN_SPACE}..."
124
+ # Now install the rest of the packages.
125
+ # unirig_requirements.txt should contain torch-scatter, torch-cluster, spconv, flash_attn (if needed), bpy, etc.
126
+ # with their respective find-links URLs or direct package names.
127
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE_IN_SPACE}" -vvv
128
 
129
  echo "Dependency installation for Blender's Python complete."