-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild_workstation_ubuntu_cuda128.sh
More file actions
executable file
·166 lines (140 loc) · 4.86 KB
/
build_workstation_ubuntu_cuda128.sh
File metadata and controls
executable file
·166 lines (140 loc) · 4.86 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
#!/usr/bin/env bash
# Build the Linux CUDA workstation bundle (painter + trainer) as an AppImage.
#
# Usage:
# ./build_workstation_ubuntu_cuda128.sh # RTX 5000 series (sm_120)
# ./build_workstation_ubuntu_cuda128.sh rtx50 # same as above
# ./build_workstation_ubuntu_cuda128.sh broad # GTX 1660 through RTX 4090
#
# PyTorch wheels: uses local wheels from ./dist/ if present (built by
# ./build_custom_torch.sh), otherwise falls back to the URLs in
# trainer/requirements_torch_cu128_<variant>.txt.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
PYTHON="${PYTHON:-python}"
VARIANT="${1:-rtx50}"
VERSION=$(grep -oP 'Version: \K[0-9.]+' "$ROOT/painter/src/main/python/about.py")
case "$VARIANT" in
rtx50)
REQUIREMENTS="requirements_torch_cu128.txt"
APPIMAGE_NAME="RootPainterWorkstation_${VERSION}_Ubuntu_CUDA128_RTX50.AppImage"
;;
broad)
REQUIREMENTS="requirements_torch_cu128_broad.txt"
APPIMAGE_NAME="RootPainterWorkstation_${VERSION}_Ubuntu_CUDA128_GTX1660_to_RTX4090.AppImage"
;;
*)
echo "ERROR: Unknown variant '$VARIANT'. Use 'rtx50' or 'broad'."
exit 1
;;
esac
echo "Building variant: $VARIANT"
echo " Requirements: $REQUIREMENTS"
echo " AppImage: $APPIMAGE_NAME"
echo ""
# Fail fast if interpreter isn't available
command -v "$PYTHON" >/dev/null 2>&1 || {
echo "ERROR: $PYTHON not found. Set PYTHON=/path/to/python"
exit 1
}
# Enforce Python 3.11 (without hardcoding binary name)
"$PYTHON" -c 'import sys; assert sys.version_info[:2]==(3,11), sys.version' || {
echo "ERROR: Python 3.11 required. Current: $("$PYTHON" -V 2>&1)"
exit 1
}
# --------------------
# Trainer
# --------------------
cd "$ROOT/trainer"
rm -rf env
"$PYTHON" -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements_base_no_torch.txt
# Use local wheels if available, otherwise fall back to requirements file
TORCH_WHEEL=$(ls "$ROOT"/dist/torch-*.whl 2>/dev/null | head -1 || true)
VISION_WHEEL=$(ls "$ROOT"/dist/torchvision-*.whl 2>/dev/null | head -1 || true)
if [ -n "$TORCH_WHEEL" ] && [ -n "$VISION_WHEEL" ]; then
echo "Using local wheels:"
echo " $TORCH_WHEEL"
echo " $VISION_WHEEL"
python -m pip install "$TORCH_WHEEL" "$VISION_WHEEL"
# Install CUDA runtime libs (custom wheel doesn't declare pip deps on these)
python -m pip install nvidia-cublas-cu12 nvidia-cuda-cupti-cu12 \
nvidia-cuda-runtime-cu12 nvidia-cudnn-cu12 nvidia-curand-cu12 \
nvidia-nvjitlink-cu12 nvidia-cuda-nvrtc-cu12
else
echo "No local wheels in ./dist/, using $REQUIREMENTS"
python -m pip install -r "$REQUIREMENTS"
fi
python -m pip install pyinstaller
python src/build/run_pyinstaller_trainer.py
deactivate
# --------------------
# Painter
# --------------------
cd "$ROOT/painter"
rm -rf env
"$PYTHON" -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pyinstaller
python src/build/run_pyinstaller_workstation.py
deactivate
# --------------------
# Bundle trainer
# --------------------
APP_DIR="$ROOT/painter/dist/RootPainterWorkstation"
rm -rf "$APP_DIR/RootPainterTrainerBundle"
cp -R "$ROOT/trainer/src/dist/RootPainterTrainer" \
"$APP_DIR/RootPainterTrainerBundle"
chmod +x "$APP_DIR/RootPainterTrainerBundle/RootPainterTrainer"
# Remove the broken trainer EXE from the workstation spec (painter venv has no torch).
# The working trainer is in RootPainterTrainerBundle/.
rm -f "$APP_DIR/RootPainterTrainer"
# --------------------
# AppImage
# --------------------
APPDIR="$ROOT/painter/dist/RootPainter.AppDir"
rm -rf "$APPDIR"
mkdir -p "$APPDIR"
# Move the workstation contents into the AppDir
mv "$APP_DIR"/* "$APPDIR"/
rmdir "$APP_DIR"
# AppRun entry point
cat > "$APPDIR/AppRun" << 'APPRUN'
#!/bin/bash
HERE="$(dirname "$(readlink -f "$0")")"
exec "$HERE/RootPainter" "$@"
APPRUN
chmod +x "$APPDIR/AppRun"
# Desktop file
cat > "$APPDIR/RootPainter.desktop" << 'DESKTOP'
[Desktop Entry]
Name=RootPainter
Comment=Corrective annotation for biological image segmentation
Exec=RootPainter
Icon=RootPainter
Type=Application
Categories=Science;Education;Graphics;
DESKTOP
# Icon
cp "$ROOT/painter/src/main/icons/linux/256.png" "$APPDIR/RootPainter.png"
# Download appimagetool if not present
APPIMAGETOOL="$ROOT/painter/dist/appimagetool"
if [ ! -x "$APPIMAGETOOL" ]; then
echo "Downloading appimagetool..."
curl -fSL -o "$APPIMAGETOOL" \
"https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x "$APPIMAGETOOL"
fi
# Build AppImage
export ARCH=x86_64
APPIMAGE_OUT="$ROOT/painter/dist/$APPIMAGE_NAME"
"$APPIMAGETOOL" --no-appstream "$APPDIR" "$APPIMAGE_OUT" \
|| "$APPIMAGETOOL" --appimage-extract-and-run --no-appstream "$APPDIR" "$APPIMAGE_OUT"
echo ""
echo "Built Ubuntu CUDA workstation AppImage ($VARIANT):"
echo "$APPIMAGE_OUT"
ls -lh "$APPIMAGE_OUT"