-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSimWorld-Studio.sh
More file actions
139 lines (127 loc) · 4.3 KB
/
SimWorld-Studio.sh
File metadata and controls
139 lines (127 loc) · 4.3 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
#!/bin/bash
# SimWorld Studio - Launch Script
# Usage: ./SimWorld-Studio.sh [--gpu INDEX] [--render-offscreen] [--port PORT]
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENGINE_DIR="$SCRIPT_DIR/Engine"
PROJECT_DIR="$SCRIPT_DIR/gym_citynav"
PROJECT_FILE="$PROJECT_DIR/gym_citynav.uproject"
UE_EDITOR="$ENGINE_DIR/Binaries/Linux/UnrealEditor"
# Default settings
MCP_PORT=55559
GPU_INDEX=""
RENDER_OFFSCREEN=""
RESOLUTION="-ResX=1280 -ResY=720"
PIXEL_STREAMING_ARGS=""
FPSMAX=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--port)
MCP_PORT="$2"
shift 2
;;
--gpu)
GPU_INDEX="$2"
shift 2
;;
--render-offscreen)
RENDER_OFFSCREEN="-RenderOffScreen"
# In headless server mode, throttle the editor to save GPU.
# Interactive editing should NOT have this — it makes Slate UI laggy.
FPSMAX="-FPSMAX=15"
shift
;;
--pixel-streaming)
PIXEL_STREAMING_ARGS="-PixelStreamingIP=127.0.0.1 -PixelStreamingPort=8586"
shift
;;
--res)
RESOLUTION="-ResX=$2 -ResY=$3"
shift 3
;;
--help|-h)
echo "SimWorld Studio Launcher"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --gpu INDEX GPU index to use (default: 0). Required on multi-GPU systems."
echo " --render-offscreen Run without display window (headless mode)"
echo " --port PORT MCP TCP port (default: 55559)"
echo " --pixel-streaming Enable Pixel Streaming on port 8586"
echo " --res WIDTH HEIGHT Set resolution (default: 1280 720)"
echo " --help Show this help"
echo ""
echo "Examples:"
echo " $0 --gpu 0 --render-offscreen # Headless on GPU 0"
echo " $0 --gpu 1 --render-offscreen --port 55560 # GPU 1, custom port"
exit 0
;;
*)
echo "Unknown option: $1 (use --help for usage)"
exit 1
;;
esac
done
# Check if editor exists
if [ ! -f "$UE_EDITOR" ]; then
echo "ERROR: UnrealEditor not found at $UE_EDITOR"
echo "Make sure you extracted the SimWorld-Studio-Minimal archive correctly."
exit 1
fi
# Check if project exists
if [ ! -f "$PROJECT_FILE" ]; then
echo "ERROR: Project file not found at $PROJECT_FILE"
exit 1
fi
# --- GPU isolation for multi-GPU systems ---
# On multi-GPU servers, Vulkan can crash trying to enumerate all GPUs.
# We isolate to a single GPU using CUDA_VISIBLE_DEVICES and VK_DRIVER_FILES.
if [ -n "$GPU_INDEX" ]; then
export CUDA_VISIBLE_DEVICES="$GPU_INDEX"
# Try to find the Vulkan ICD file for GPU isolation
# This prevents Vulkan from enumerating all GPUs (which causes crashes)
NVIDIA_ICD="/usr/share/vulkan/icd.d/nvidia_icd.json"
if [ -f "$NVIDIA_ICD" ]; then
export VK_ICD_FILENAMES="$NVIDIA_ICD"
fi
# Also set the UE graphics adapter flag
GPU_ADAPTER="-graphicsadapter=$GPU_INDEX"
else
# Default to GPU 0 on multi-GPU systems to avoid Vulkan enumeration issues
GPU_COUNT=$(nvidia-smi --query-gpu=count --format=csv,noheader 2>/dev/null | head -1 || echo "1")
if [ "$GPU_COUNT" -gt 1 ] 2>/dev/null; then
echo "WARNING: Multi-GPU system detected ($GPU_COUNT GPUs)."
echo " Defaulting to GPU 0. Use --gpu INDEX to select a specific GPU."
echo ""
export CUDA_VISIBLE_DEVICES="0"
GPU_ADAPTER="-graphicsadapter=0"
NVIDIA_ICD="/usr/share/vulkan/icd.d/nvidia_icd.json"
if [ -f "$NVIDIA_ICD" ]; then
export VK_ICD_FILENAMES="$NVIDIA_ICD"
fi
else
GPU_ADAPTER=""
fi
fi
echo "=== SimWorld Studio ==="
echo " Engine: $UE_EDITOR"
echo " Project: $PROJECT_FILE"
echo " MCP Port: $MCP_PORT"
echo " GPU: ${GPU_INDEX:-auto}"
echo " Map: /Game/Maps/Empty"
echo ""
# Launch UE Editor
exec "$UE_EDITOR" "$PROJECT_FILE" \
/Game/Maps/Empty.umap \
-MCPPort=$MCP_PORT \
-NOSPLASH \
-NOSOUND \
$RESOLUTION \
$FPSMAX \
$GPU_ADAPTER \
$RENDER_OFFSCREEN \
$PIXEL_STREAMING_ARGS \
-log \
"$@"