From c5a04a5fa7feadce9f2a51a97336e09490aa0087 Mon Sep 17 00:00:00 2001 From: connorsoohoo Date: Sun, 28 Jun 2026 21:55:05 -0600 Subject: [PATCH 1/3] fix(mac): get training and inference working on macOS - Comment out CUDA-only dependencies (xformers, gsplat) in pyproject.toml and requirements.txt with explanatory comments. - Restrict requires-python to >=3.10 to resolve dependency resolution conflict with gradio>=5. - Set KMP_DUPLICATE_LIB_OK=TRUE at the top of cli.py to prevent OpenMP crashes. - Fix NameError in CLI by renaming reference_view_strategy to ref_view_strategy in run_inference calls. --- pyproject.toml | 9 +++++---- requirements.txt | 2 +- src/depth_anything_3/cli.py | 13 +++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6a11c7ae..7538257a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "depth-anything-3" version = "0.0.0" description = "Depth Anything 3" readme = "README.md" -requires-python = ">=3.9, <=3.13" +requires-python = ">=3.10, <=3.13" license = { text = "Apache-2.0" } authors = [{ name = "Your Name" }] @@ -21,7 +21,7 @@ dependencies = [ "imageio", "numpy<2", "opencv-python", - "xformers", + # "xformers", # Commented out to support macOS/MPS/CPU (xformers is CUDA-only) "open3d", "fastapi", "uvicorn", @@ -43,8 +43,9 @@ dependencies = [ [project.optional-dependencies] app = ["gradio>=5", "pillow>=9.0"] # requires that python3>=3.10 -gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70"] -all = ["depth-anything-3[app,gs]"] +# Commented out to support macOS/MPS/CPU (gsplat requires CUDA compilation) +# gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70"] +# all = ["depth-anything-3[app,gs]"] [project.scripts] diff --git a/requirements.txt b/requirements.txt index 878db3f3..0300fc82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ huggingface_hub imageio numpy<2 opencv-python -xformers +# xformers # Commented out to support macOS/MPS/CPU (CUDA-only) open3d fastapi uvicorn diff --git a/src/depth_anything_3/cli.py b/src/depth_anything_3/cli.py index c9463028..1e94b02d 100644 --- a/src/depth_anything_3/cli.py +++ b/src/depth_anything_3/cli.py @@ -20,6 +20,9 @@ from __future__ import annotations import os +os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" # Prevent OpenMP double initialization crash on macOS +os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" + import typer from depth_anything_3.services import start_server @@ -40,8 +43,6 @@ DEFAULT_MODEL, ) -os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" - app = typer.Typer(help="Depth Anything 3 - Video depth estimation CLI", add_completion=False) @@ -380,7 +381,7 @@ def image( process_res_method=process_res_method, export_feat_layers=export_feat_layers, use_ray_pose=use_ray_pose, - reference_view_strategy=reference_view_strategy, + ref_view_strategy=ref_view_strategy, # Changed from reference_view_strategy to fix NameError conf_thresh_percentile=conf_thresh_percentile, num_max_points=num_max_points, show_cameras=show_cameras, @@ -459,7 +460,7 @@ def images( process_res_method=process_res_method, export_feat_layers=export_feat_layers, use_ray_pose=use_ray_pose, - reference_view_strategy=reference_view_strategy, + ref_view_strategy=ref_view_strategy, # Changed from reference_view_strategy to fix NameError conf_thresh_percentile=conf_thresh_percentile, num_max_points=num_max_points, show_cameras=show_cameras, @@ -546,7 +547,7 @@ def colmap( intrinsics=intrinsics, align_to_input_ext_scale=align_to_input_ext_scale, use_ray_pose=use_ray_pose, - reference_view_strategy=reference_view_strategy, + ref_view_strategy=ref_view_strategy, # Changed from reference_view_strategy to fix NameError conf_thresh_percentile=conf_thresh_percentile, num_max_points=num_max_points, show_cameras=show_cameras, @@ -623,7 +624,7 @@ def video( process_res_method=process_res_method, export_feat_layers=export_feat_layers, use_ray_pose=use_ray_pose, - reference_view_strategy=reference_view_strategy, + ref_view_strategy=ref_view_strategy, # Changed from reference_view_strategy to fix NameError conf_thresh_percentile=conf_thresh_percentile, num_max_points=num_max_points, show_cameras=show_cameras, From ad1be743e6851932d56a72553a636dd90ef6bd75 Mon Sep 17 00:00:00 2001 From: connorsoohoo Date: Sun, 28 Jun 2026 21:58:21 -0600 Subject: [PATCH 2/3] refactor(mac): use sys_platform environment markers instead of commenting out dependencies --- pyproject.toml | 7 +++---- requirements.txt | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7538257a..a5ce5206 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "imageio", "numpy<2", "opencv-python", - # "xformers", # Commented out to support macOS/MPS/CPU (xformers is CUDA-only) + "xformers; sys_platform != 'darwin'", "open3d", "fastapi", "uvicorn", @@ -43,9 +43,8 @@ dependencies = [ [project.optional-dependencies] app = ["gradio>=5", "pillow>=9.0"] # requires that python3>=3.10 -# Commented out to support macOS/MPS/CPU (gsplat requires CUDA compilation) -# gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70"] -# all = ["depth-anything-3[app,gs]"] +gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70; sys_platform != 'darwin'"] +all = ["depth-anything-3[app,gs]"] [project.scripts] diff --git a/requirements.txt b/requirements.txt index 0300fc82..f3bd7c9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ huggingface_hub imageio numpy<2 opencv-python -# xformers # Commented out to support macOS/MPS/CPU (CUDA-only) +xformers; sys_platform != 'darwin' open3d fastapi uvicorn From 96d77a35dfa242ff66c1dcc9f1f9e7ce793e282b Mon Sep 17 00:00:00 2001 From: connorsoohoo Date: Sun, 28 Jun 2026 22:07:10 -0600 Subject: [PATCH 3/3] revert: comment out CUDA-only dependencies to prevent uv universal resolution error --- pyproject.toml | 7 ++++--- requirements.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5ce5206..7538257a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "imageio", "numpy<2", "opencv-python", - "xformers; sys_platform != 'darwin'", + # "xformers", # Commented out to support macOS/MPS/CPU (xformers is CUDA-only) "open3d", "fastapi", "uvicorn", @@ -43,8 +43,9 @@ dependencies = [ [project.optional-dependencies] app = ["gradio>=5", "pillow>=9.0"] # requires that python3>=3.10 -gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70; sys_platform != 'darwin'"] -all = ["depth-anything-3[app,gs]"] +# Commented out to support macOS/MPS/CPU (gsplat requires CUDA compilation) +# gs = ["gsplat @ git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70"] +# all = ["depth-anything-3[app,gs]"] [project.scripts] diff --git a/requirements.txt b/requirements.txt index f3bd7c9a..0300fc82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ huggingface_hub imageio numpy<2 opencv-python -xformers; sys_platform != 'darwin' +# xformers # Commented out to support macOS/MPS/CPU (CUDA-only) open3d fastapi uvicorn