-
Notifications
You must be signed in to change notification settings - Fork 41
/
horde-bridge-rocm.sh
executable file
·54 lines (45 loc) · 1.8 KB
/
horde-bridge-rocm.sh
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
#!/bin/bash
# Get the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Build the absolute path to the Conda environment
CONDA_ENV_PATH="$SCRIPT_DIR/conda/envs/linux/lib"
# Determine if the user has a flash attention supported card.
SUPPORTED_CARD=$(rocminfo | grep -c -e gfx1100 -e gfx1101 -e gfx1102)
if [ "$SUPPORTED_CARD" -gt 0 ]; then export FLASH_ATTENTION_USE_TRITON_ROCM="${FLASH_ATTENTION_USE_TRITON_ROCM:=TRUE}"; fi
export MIOPEN_FIND_MODE="FAST"
# Add the Conda environment to LD_LIBRARY_PATH
export LD_LIBRARY_PATH="$CONDA_ENV_PATH:$LD_LIBRARY_PATH"
# Set torch garbage cleanup. Amd defaults cause problems. //this was less stable than the torch 2.5.0 defaults in my testing
#export PYTORCH_HIP_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:2048
# List of directories to check
dirs=(
"/usr/lib"
"/usr/local/lib"
"/lib"
"/lib64"
"/usr/lib/x86_64-linux-gnu"
)
# Check each directory
for dir in "${dirs[@]}"; do
if [ -f "$dir/libjemalloc.so.2" ]; then
export LD_PRELOAD="$dir/libjemalloc.so.2"
printf "Using jemalloc from $dir\n"
break
fi
done
# If jemalloc was not found, print a warning
if [ -z "$LD_PRELOAD" ]; then
printf "WARNING: jemalloc not found. You may run into memory issues! We recommend running `sudo apt install libjemalloc2`\n"
# Press q to quit or any other key to continue
read -n 1 -s -r -p "Press q to quit or any other key to continue: " key
if [ "$key" = "q" ]; then
printf "\n"
exit 1
fi
fi
if "$SCRIPT_DIR/runtime-rocm.sh" python -s "$SCRIPT_DIR/download_models.py"; then
echo "Model Download OK. Starting worker..."
"$SCRIPT_DIR/runtime-rocm.sh" python -s "$SCRIPT_DIR/run_worker.py" $*
else
echo "download_models.py exited with error code. Aborting"
fi