HongzeFu commited on
Commit
3da5127
·
1 Parent(s): ac91894

v3 vulkan icd

Browse files
Files changed (3) hide show
  1. Dockerfile +5 -1
  2. docker-entrypoint.sh +49 -0
  3. gradio-web/main.py +16 -0
Dockerfile CHANGED
@@ -31,6 +31,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
31
  ENV PYTHONUNBUFFERED=1 \
32
  PIP_NO_CACHE_DIR=1 \
33
  NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics \
 
 
 
34
  PORT=7860
35
 
36
  RUN useradd -m -u 1000 user
@@ -42,9 +45,10 @@ RUN python3 -m pip install --upgrade pip setuptools wheel \
42
 
43
  COPY --chown=user:user . .
44
  RUN python3 -m pip install -e .
45
- RUN chown -R user:user /home/user/app
46
 
47
  USER user
48
  EXPOSE 7860
 
49
 
50
  CMD ["python3", "gradio-web/main.py"]
 
31
  ENV PYTHONUNBUFFERED=1 \
32
  PIP_NO_CACHE_DIR=1 \
33
  NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics \
34
+ HOME=/home/user \
35
+ PATH=/home/user/.local/bin:$PATH \
36
+ OMP_NUM_THREADS=1 \
37
  PORT=7860
38
 
39
  RUN useradd -m -u 1000 user
 
45
 
46
  COPY --chown=user:user . .
47
  RUN python3 -m pip install -e .
48
+ RUN chmod +x /home/user/app/docker-entrypoint.sh
49
 
50
  USER user
51
  EXPOSE 7860
52
+ ENTRYPOINT ["./docker-entrypoint.sh"]
53
 
54
  CMD ["python3", "gradio-web/main.py"]
docker-entrypoint.sh ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ pick_vulkan_icd() {
5
+ for candidate in \
6
+ /etc/vulkan/icd.d/nvidia_icd.json \
7
+ /etc/vulkan/icd.d/nvidia_icd.x86_64.json \
8
+ /usr/share/vulkan/icd.d/nvidia_icd.json \
9
+ /usr/share/vulkan/icd.d/nvidia_icd.x86_64.json
10
+ do
11
+ if [ -f "$candidate" ]; then
12
+ printf '%s\n' "$candidate"
13
+ return 0
14
+ fi
15
+ done
16
+ return 1
17
+ }
18
+
19
+ run_diagnostic() {
20
+ label="$1"
21
+ shift
22
+ echo "[entrypoint] $label"
23
+ if "$@"; then
24
+ return 0
25
+ fi
26
+ status=$?
27
+ echo "[entrypoint] $label failed with exit code $status"
28
+ return 0
29
+ }
30
+
31
+ if [ -z "${OMP_NUM_THREADS:-}" ]; then
32
+ export OMP_NUM_THREADS=1
33
+ fi
34
+
35
+ if [ -z "${VK_ICD_FILENAMES:-}" ]; then
36
+ if detected_icd="$(pick_vulkan_icd)"; then
37
+ export VK_ICD_FILENAMES="$detected_icd"
38
+ echo "[entrypoint] Using Vulkan ICD: $VK_ICD_FILENAMES"
39
+ else
40
+ echo "[entrypoint] Vulkan ICD file not found under /etc or /usr/share"
41
+ fi
42
+ else
43
+ echo "[entrypoint] Respecting preset VK_ICD_FILENAMES: $VK_ICD_FILENAMES"
44
+ fi
45
+
46
+ echo "[entrypoint] OMP_NUM_THREADS=$OMP_NUM_THREADS"
47
+ run_diagnostic "nvidia-smi" nvidia-smi
48
+ run_diagnostic "vulkaninfo --summary" vulkaninfo --summary
49
+ exec "$@"
gradio-web/main.py CHANGED
@@ -59,6 +59,21 @@ def setup_logging() -> logging.Logger:
59
  LOGGER = setup_logging()
60
 
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  def ensure_media_dirs():
63
  """Ensure media temp directories exist before first write."""
64
  TEMP_DEMOS_DIR.mkdir(parents=True, exist_ok=True)
@@ -97,6 +112,7 @@ def main():
97
  from ui_layout import create_ui_blocks
98
 
99
  LOGGER.info("Starting Gradio real environment entrypoint: %s", __file__)
 
100
  ensure_media_dirs()
101
  start_timeout_monitor()
102
 
 
59
  LOGGER = setup_logging()
60
 
61
 
62
+ def log_runtime_graphics_env():
63
+ """Log graphics-related runtime env so Spaces diagnostics are visible in stdout."""
64
+ keys = [
65
+ "CUDA_VISIBLE_DEVICES",
66
+ "NVIDIA_VISIBLE_DEVICES",
67
+ "NVIDIA_DRIVER_CAPABILITIES",
68
+ "VK_ICD_FILENAMES",
69
+ "OMP_NUM_THREADS",
70
+ "SAPIEN_RENDER_DEVICE",
71
+ "MUJOCO_GL",
72
+ ]
73
+ snapshot = {key: os.getenv(key) for key in keys}
74
+ LOGGER.info("Runtime graphics env: %s", snapshot)
75
+
76
+
77
  def ensure_media_dirs():
78
  """Ensure media temp directories exist before first write."""
79
  TEMP_DEMOS_DIR.mkdir(parents=True, exist_ok=True)
 
112
  from ui_layout import create_ui_blocks
113
 
114
  LOGGER.info("Starting Gradio real environment entrypoint: %s", __file__)
115
+ log_runtime_graphics_env()
116
  ensure_media_dirs()
117
  start_timeout_monitor()
118