-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
209 lines (184 loc) · 6.73 KB
/
Copy pathinstall.sh
File metadata and controls
209 lines (184 loc) · 6.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# 100% credit to chia and chia dev team - https://github.com/Chia-Network/chia-blockchain
set -o errexit
UBUNTU=false
DEBIAN=false
MACOS=false
if [ "$(uname)" = "Linux" ]; then
#LINUX=1
if command -v apt-get >/dev/null; then
if command -v lsb_release >/dev/null; then
OS_ID=$(lsb_release -is)
if [ "$OS_ID" = "Debian" ]; then
DEBIAN=true
else
UBUNTU=true
fi
fi
fi
elif [ "$(uname)" = "Darwin" ]; then
MACOS=true
fi
# Check for non 64 bit ARM64/Raspberry Pi installs
if [ "$(uname -m)" = "armv7l" ]; then
echo ""
echo "WARNING:"
echo "diffusers-workflow requires a 64 bit OS and this is 32 bit armv7l"
echo "Exiting."
exit 1
fi
UBUNTU_PRE_20=0
UBUNTU_20=0
UBUNTU_21=0
UBUNTU_22=0
if $UBUNTU; then
if command -v lsb_release >/dev/null; then
LSB_RELEASE=$(lsb_release -rs)
# In case Ubuntu minimal does not come with bc
if ! command -v bc > /dev/null 2>&1; then
sudo apt install bc -y
fi
# Mint 20.04 responds with 20 here so 20 instead of 20.04
if [ "$(echo "$LSB_RELEASE<20" | bc)" = "1" ]; then
UBUNTU_PRE_20=1
elif [ "$(echo "$LSB_RELEASE<21" | bc)" = "1" ]; then
UBUNTU_20=1
elif [ "$(echo "$LSB_RELEASE<22" | bc)" = "1" ]; then
UBUNTU_21=1
else
UBUNTU_22=1
fi
fi
fi
# You can specify preferred python version by exporting `INSTALL_PYTHON_VERSION`
# e.g. `export INSTALL_PYTHON_VERSION=3.8`
INSTALL_PYTHON_PATH=
PYTHON_MAJOR_VER=
PYTHON_MINOR_VER=
find_python() {
set +e
unset BEST_VERSION
for V in 314 3.14 313 3.13 312 3.12 311 3.11 310 3.10; do
if command -v python$V >/dev/null; then
if [ "$BEST_VERSION" = "" ]; then
BEST_VERSION=$V
fi
fi
done
if [ -n "$BEST_VERSION" ]; then
INSTALL_PYTHON_VERSION="$BEST_VERSION"
INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION}
PY3_VER=$($INSTALL_PYTHON_PATH --version | cut -d ' ' -f2)
PYTHON_MAJOR_VER=$(echo "$PY3_VER" | cut -d'.' -f1)
PYTHON_MINOR_VER=$(echo "$PY3_VER" | cut -d'.' -f2)
fi
set -e
}
if [ "$INSTALL_PYTHON_VERSION" = "" ]; then
echo "Searching available python executables..."
find_python
else
echo "Python $INSTALL_PYTHON_VERSION is requested"
INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION}
PY3_VER=$($INSTALL_PYTHON_PATH --version | cut -d ' ' -f2)
PYTHON_MAJOR_VER=$(echo "$PY3_VER" | cut -d'.' -f1)
PYTHON_MINOR_VER=$(echo "$PY3_VER" | cut -d'.' -f2)
fi
if ! command -v "$INSTALL_PYTHON_PATH" >/dev/null; then
echo "${INSTALL_PYTHON_PATH} was not found"
exit 1
fi
if [ "$PYTHON_MAJOR_VER" -ne "3" ] || [ "$PYTHON_MINOR_VER" -lt "10" ] || [ "$PYTHON_MINOR_VER" -ge "15" ]; then
echo "diffusers-workflow requires Python version >= 3.10 and <= 3.14" >&2
echo "Current Python version = $INSTALL_PYTHON_VERSION" >&2
# If Arch, direct to Arch Wiki
if type pacman >/dev/null 2>&1 && [ -f "/etc/arch-release" ]; then
echo "Please see https://wiki.archlinux.org/title/python#Old_versions for support." >&2
fi
exit 1
fi
echo "Python version is $INSTALL_PYTHON_VERSION"
# Delete the venv folder if present
if [ -d "venv" ]; then
rm -rf ./venv
fi
# Create the venv and add soft link to activate
$INSTALL_PYTHON_PATH -m venv venv
if [ ! -f "activate" ]; then
ln -s venv/bin/activate .
fi
# Activate the virtual environment
# shellcheck disable=SC1091
. ./activate
# Upgrade pip
python -m pip install --upgrade pip
# Install PyTorch first - platform/GPU-aware, so the resolver below sees it
# satisfied and leaves it alone. torchaudio comes with it, from the same index
# so its build matches: dw does not import it, but diffusers' MiniMax H3 blocks
# use it to resample an audio reference that is not already at the audio VAE's
# rate, and without it those pipelines fail at the first setup block.
#
# On macOS PyPI's wheel is the right one (MPS support is built in). On
# Linux, PyPI's wheel bundles a CUDA 12.x runtime; pytorch.org's cu130
# index carries a CUDA 13 build that needs a newer driver (>= 580). So we
# probe for a working NVIDIA driver via nvidia-smi and, if found, read the
# CUDA version it supports: a CUDA 13-capable driver gets the cu130 build,
# an older one stays on PyPI's CUDA 12 wheel rather than a build its driver
# cannot load (which would silently fall back to the CPU).
if $MACOS; then
echo "macOS detected - installing torch with MPS support"
pip install torch torchvision torchaudio
else
DRIVER_CUDA=""
# `command -v` alone only proves the binary exists; a stale/broken driver
# can leave nvidia-smi installed but failing, so also require it to run.
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi >/dev/null 2>&1; then
DRIVER_CUDA=$(nvidia-smi 2>/dev/null | grep -o 'CUDA Version: [0-9]*' | grep -o '[0-9]*$' || true)
DRIVER_CUDA=${DRIVER_CUDA:-12}
fi
if [ -z "$DRIVER_CUDA" ]; then
echo "No CUDA GPU detected - installing CPU-only torch"
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
elif [ "$DRIVER_CUDA" -ge 13 ]; then
echo "CUDA $DRIVER_CUDA driver detected - installing GPU-enabled torch (cu130)"
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
else
echo "CUDA $DRIVER_CUDA driver detected - installing PyPI torch (bundled CUDA 12 runtime)"
pip install torch torchvision torchaudio
fi
fi
# Everything else resolves from pyproject.toml - the single source of the
# dependency list (bitsandbytes included, via its linux platform marker).
# Editable install with the server + dev extras.
pip install -e ".[server,dev]"
# Diffusers from GitHub (releases lag the newest model pipelines) - after
# the resolver, so it isn't replaced by the released version
pip install --upgrade git+https://github.com/huggingface/diffusers
# Platform-specific extras pyproject can't express
if $MACOS; then
# FP8/FP4 dtype support for MPS (auto-activates via torch.backends)
pip install fp4-fp8-for-torch-mps fluidtop
fi
# Web UI dependencies - optional, only needed to build/run the SPA served by dw-serve
if command -v npm >/dev/null; then
echo ""
echo "Installing web UI dependencies..."
(cd ui && npm install)
else
echo ""
echo "npm was not found - skipping web UI dependency install."
echo "Install Node.js/npm and run 'npm install' in the ui/ folder to build the web UI."
fi
echo ""
echo "Installation complete!"
echo ""
echo "To activate the virtual environment, run:"
echo " . ./activate"
echo ""
if $MACOS; then
echo "Note: Running on Apple Silicon with MPS (Metal Performance Shaders) backend."
echo "Some features (bitsandbytes quantization, flash_attn) are not available on macOS."
else
echo "Note: Some LLM workflows (e.g., Phi mini-instruct) require flash_attn,"
echo "which requires the CUDA Toolkit: https://developer.nvidia.com/cuda-toolkit"
fi