jkorstad commited on
Commit
5c9a178
·
verified ·
1 Parent(s): a4745e1

Update setup_blender.sh

Browse files
Files changed (1) hide show
  1. setup_blender.sh +20 -29
setup_blender.sh CHANGED
@@ -5,19 +5,18 @@ set -e
5
 
6
  # --- Configuration ---
7
  BLENDER_VERSION="4.2.0"
8
- BLENDER_MAJOR_MINOR="4.2" # Matches the version directory structure
9
- BLENDER_PYTHON_VERSION="python3.11" # Blender 4.2 uses Python 3.11
10
  BLENDER_TARBALL="blender-${BLENDER_VERSION}-linux-x64.tar.xz"
11
  BLENDER_URL="https://download.blender.org/release/Blender${BLENDER_MAJOR_MINOR}/blender-${BLENDER_VERSION}-linux-x64.tar.xz"
12
  INSTALL_DIR="/opt/blender-${BLENDER_VERSION}-linux-x64"
13
  BLENDER_PY_EXEC="${INSTALL_DIR}/${BLENDER_MAJOR_MINOR}/python/bin/${BLENDER_PYTHON_VERSION}"
14
- # Assuming unirig_requirements.txt is in the root directory alongside this script and app.py
15
- UNIRIG_REQS_FILE="unirig_requirements.txt"
16
- # Define the specific torch version and index URL (matching unirig_requirements.txt)
17
  TORCH_VERSION="2.3.1"
18
  TORCHVISION_VERSION="0.18.1"
19
- TORCH_CUDA_SUFFIX="cu121" # CUDA version suffix for wheels
20
- TORCH_INDEX_URL="https://download.pytorch.org/whl/${TORCH_CUDA_SUFFIX}" # Make sure this matches your target CUDA
 
21
 
22
  # --- Download and Extract Blender ---
23
  echo "Downloading Blender ${BLENDER_VERSION}..."
@@ -25,56 +24,48 @@ wget -nv -O /tmp/${BLENDER_TARBALL} ${BLENDER_URL}
25
  echo "Download complete."
26
 
27
  echo "Extracting Blender to ${INSTALL_DIR}..."
28
- mkdir -p /opt # Ensure /opt exists
29
  tar -xJf /tmp/${BLENDER_TARBALL} -C /opt
30
  echo "Extraction complete."
31
 
32
  # --- Create Blender Symlink ---
33
  echo "Creating symlink for Blender executable..."
34
- ln -sf ${INSTALL_DIR}/blender /usr/local/bin/blender # Use -f to force overwrite if exists
35
  echo "Symlink created."
36
 
37
- # --- Install UniRig Dependencies into Blender's Python ---
38
- echo "Installing UniRig Python dependencies into Blender's Python (${BLENDER_PYTHON_VERSION})..."
39
 
40
  if [ ! -f "${BLENDER_PY_EXEC}" ]; then
41
- echo "ERROR: Blender Python executable not found at ${BLENDER_PY_EXEC} after extraction!"
42
  exit 1
43
  fi
44
 
45
  if [ ! -f "${UNIRIG_REQS_FILE}" ]; then
46
- echo "ERROR: UniRig requirements file not found at ${UNIRIG_REQS_FILE}!"
47
- echo "Ensure this file exists in the root directory."
48
  exit 1
49
  fi
50
 
51
- # Upgrade pip within Blender's Python environment
52
  echo "Upgrading pip for Blender Python..."
53
  "${BLENDER_PY_EXEC}" -m pip install --upgrade pip setuptools wheel
54
 
55
- # --- Install PyTorch and Torchvision FIRST ---
56
- # This is crucial because torch-scatter/torch-cluster setup needs torch.
57
- echo "Installing PyTorch ${TORCH_VERSION} and Torchvision ${TORCHVISION_VERSION} first (CUDA: ${TORCH_CUDA_SUFFIX})..."
58
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
59
  torch==${TORCH_VERSION} \
60
  torchvision==${TORCHVISION_VERSION} \
61
  --index-url ${TORCH_INDEX_URL}
62
 
63
- echo "PyTorch and Torchvision installation complete."
 
 
64
 
65
- # --- Install the rest of the packages from unirig_requirements.txt SECOND ---
66
- # This will now install torch-scatter, torch-cluster (using the -f flags in the file),
67
- # and all other dependencies. Pip will skip torch/torchvision as they are already installed.
68
- # Added --no-build-isolation to potentially help builds find already installed packages like torch.
69
- echo "Installing remaining packages from ${UNIRIG_REQS_FILE} (including torch-scatter/cluster via -f flags)..."
70
- "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir --no-build-isolation -r "${UNIRIG_REQS_FILE}"
71
-
72
- echo "UniRig dependency installation for Blender Python complete."
73
 
74
  # --- Cleanup ---
75
  echo "Cleaning up downloaded tarball..."
76
  rm /tmp/${BLENDER_TARBALL}
77
  echo "Cleanup complete."
78
 
79
- echo "Blender setup finished successfully."
80
-
 
5
 
6
  # --- Configuration ---
7
  BLENDER_VERSION="4.2.0"
8
+ BLENDER_MAJOR_MINOR="4.2"
9
+ BLENDER_PYTHON_VERSION="python3.11"
10
  BLENDER_TARBALL="blender-${BLENDER_VERSION}-linux-x64.tar.xz"
11
  BLENDER_URL="https://download.blender.org/release/Blender${BLENDER_MAJOR_MINOR}/blender-${BLENDER_VERSION}-linux-x64.tar.xz"
12
  INSTALL_DIR="/opt/blender-${BLENDER_VERSION}-linux-x64"
13
  BLENDER_PY_EXEC="${INSTALL_DIR}/${BLENDER_MAJOR_MINOR}/python/bin/${BLENDER_PYTHON_VERSION}"
14
+ UNIRIG_REQS_FILE="/home/user/app/unirig_requirements.txt" # Adjust path if different
 
 
15
  TORCH_VERSION="2.3.1"
16
  TORCHVISION_VERSION="0.18.1"
17
+ TORCH_CUDA_SUFFIX="cu121"
18
+ TORCH_INDEX_URL="https://download.pytorch.org/whl/${TORCH_CUDA_SUFFIX}"
19
+ PYG_WHEEL_INDEX="https://data.pyg.org/whl/torch-2.3.0+cu121.html" # Compatible with 2.3.1
20
 
21
  # --- Download and Extract Blender ---
22
  echo "Downloading Blender ${BLENDER_VERSION}..."
 
24
  echo "Download complete."
25
 
26
  echo "Extracting Blender to ${INSTALL_DIR}..."
27
+ mkdir -p /opt
28
  tar -xJf /tmp/${BLENDER_TARBALL} -C /opt
29
  echo "Extraction complete."
30
 
31
  # --- Create Blender Symlink ---
32
  echo "Creating symlink for Blender executable..."
33
+ ln -sf ${INSTALL_DIR}/blender /usr/local/bin/blender
34
  echo "Symlink created."
35
 
36
+ # --- Install Dependencies into Blender's Python ---
37
+ echo "Installing dependencies into Blender's Python (${BLENDER_PYTHON_VERSION})..."
38
 
39
  if [ ! -f "${BLENDER_PY_EXEC}" ]; then
40
+ echo "ERROR: Blender Python executable not found at ${BLENDER_PY_EXEC}!"
41
  exit 1
42
  fi
43
 
44
  if [ ! -f "${UNIRIG_REQS_FILE}" ]; then
45
+ echo "ERROR: Requirements file not found at ${UNIRIG_REQS_FILE}!"
 
46
  exit 1
47
  fi
48
 
49
+ # Upgrade pip
50
  echo "Upgrading pip for Blender Python..."
51
  "${BLENDER_PY_EXEC}" -m pip install --upgrade pip setuptools wheel
52
 
53
+ # Install PyTorch and Torchvision first
54
+ echo "Installing PyTorch ${TORCH_VERSION} and Torchvision ${TORCHVISION_VERSION} (CUDA: ${TORCH_CUDA_SUFFIX})..."
 
55
  "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir \
56
  torch==${TORCH_VERSION} \
57
  torchvision==${TORCHVISION_VERSION} \
58
  --index-url ${TORCH_INDEX_URL}
59
 
60
+ # Install remaining dependencies with PyG wheel index
61
+ echo "Installing remaining packages from ${UNIRIG_REQS_FILE} with PyG wheel index..."
62
+ "${BLENDER_PY_EXEC}" -m pip install --no-cache-dir -r "${UNIRIG_REQS_FILE}" -f ${PYG_WHEEL_INDEX}
63
 
64
+ echo "Dependency installation complete."
 
 
 
 
 
 
 
65
 
66
  # --- Cleanup ---
67
  echo "Cleaning up downloaded tarball..."
68
  rm /tmp/${BLENDER_TARBALL}
69
  echo "Cleanup complete."
70
 
71
+ echo "Blender setup finished successfully."