From df6d44fabe97d7fe5dc507fab25ae22d386f9324 Mon Sep 17 00:00:00 2001 From: LJ Date: Sat, 16 Aug 2025 23:16:41 -0700 Subject: [PATCH] chore: set `PYTORCH_ENABLE_MPS_FALLBACK=1` for examples using GPU --- examples/amazon_s3_embedding/.env.example | 4 ++++ examples/azure_blob_embedding/.env.example | 4 ++++ examples/code_embedding/.env | 4 ++++ examples/face_recognition/.env | 4 ++++ examples/fastapi_server_docker/.env | 4 ++++ examples/gdrive_text_embedding/.env.example | 4 ++++ examples/image_search/.env | 4 ++++ examples/manuals_llm_extraction/.env | 4 ++++ examples/multi_format_indexing/.env | 4 ++++ examples/paper_metadata/.env.example | 4 ++++ examples/pdf_embedding/.env | 4 ++++ examples/text_embedding/.env | 4 ++++ examples/text_embedding_qdrant/.env | 4 ++++ 13 files changed, 52 insertions(+) diff --git a/examples/amazon_s3_embedding/.env.example b/examples/amazon_s3_embedding/.env.example index 4025da55..5d05eb38 100644 --- a/examples/amazon_s3_embedding/.env.example +++ b/examples/amazon_s3_embedding/.env.example @@ -9,3 +9,7 @@ AMAZON_S3_BUCKET_NAME=your-bucket-name # Optional # AMAZON_S3_SQS_QUEUE_URL= + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/azure_blob_embedding/.env.example b/examples/azure_blob_embedding/.env.example index 0b935408..aa14f460 100644 --- a/examples/azure_blob_embedding/.env.example +++ b/examples/azure_blob_embedding/.env.example @@ -5,3 +5,7 @@ COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex AZURE_STORAGE_ACCOUNT_NAME=testnamecocoindex1 AZURE_BLOB_CONTAINER_NAME=testpublic1 AZURE_BLOB_PREFIX= + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/code_embedding/.env b/examples/code_embedding/.env index 335f3060..335feb69 100644 --- a/examples/code_embedding/.env +++ b/examples/code_embedding/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/face_recognition/.env b/examples/face_recognition/.env index 335f3060..335feb69 100644 --- a/examples/face_recognition/.env +++ b/examples/face_recognition/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/fastapi_server_docker/.env b/examples/fastapi_server_docker/.env index f685c601..036fffba 100644 --- a/examples/fastapi_server_docker/.env +++ b/examples/fastapi_server_docker/.env @@ -3,3 +3,7 @@ COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@coco_db:5436/cocoindex # For local testing # COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/gdrive_text_embedding/.env.example b/examples/gdrive_text_embedding/.env.example index 62d8fd9b..9b250188 100644 --- a/examples/gdrive_text_embedding/.env.example +++ b/examples/gdrive_text_embedding/.env.example @@ -8,3 +8,7 @@ GOOGLE_SERVICE_ACCOUNT_CREDENTIAL=/path/to/service_account_credential.json # Google Drive root folder IDs, comma separated. #! PLEASE FILL IN GOOGLE_DRIVE_ROOT_FOLDER_IDS=id1,id2 + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/image_search/.env b/examples/image_search/.env index 39b4714b..df5ab1d1 100644 --- a/examples/image_search/.env +++ b/examples/image_search/.env @@ -1 +1,5 @@ export COCOINDEX_DATABASE_URL="postgres://cocoindex:cocoindex@localhost/cocoindex" + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/manuals_llm_extraction/.env b/examples/manuals_llm_extraction/.env index 335f3060..335feb69 100644 --- a/examples/manuals_llm_extraction/.env +++ b/examples/manuals_llm_extraction/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/multi_format_indexing/.env b/examples/multi_format_indexing/.env index 335f3060..335feb69 100644 --- a/examples/multi_format_indexing/.env +++ b/examples/multi_format_indexing/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/paper_metadata/.env.example b/examples/paper_metadata/.env.example index 4e17b8fb..226502d5 100644 --- a/examples/paper_metadata/.env.example +++ b/examples/paper_metadata/.env.example @@ -2,3 +2,7 @@ COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex OPENAI_API_KEY= + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 \ No newline at end of file diff --git a/examples/pdf_embedding/.env b/examples/pdf_embedding/.env index 335f3060..335feb69 100644 --- a/examples/pdf_embedding/.env +++ b/examples/pdf_embedding/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/text_embedding/.env b/examples/text_embedding/.env index 335f3060..335feb69 100644 --- a/examples/text_embedding/.env +++ b/examples/text_embedding/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1 diff --git a/examples/text_embedding_qdrant/.env b/examples/text_embedding_qdrant/.env index 335f3060..335feb69 100644 --- a/examples/text_embedding_qdrant/.env +++ b/examples/text_embedding_qdrant/.env @@ -1,2 +1,6 @@ # Postgres database address for cocoindex COCOINDEX_DATABASE_URL=postgres://cocoindex:cocoindex@localhost/cocoindex + +# Fallback to CPU for operations not supported by MPS on Mac. +# It's no-op for other platforms. +PYTORCH_ENABLE_MPS_FALLBACK=1