Torch is not supported anymore on the MacOS Intel

I have downloaded from github the sources for the first lesson of this course, I have installed uv and I followed the instructions on how to start up the application. Unfortunately I have discovered that torch is not available for MacOS Intel anymore.

Is there a way to fix this problem?

1 Like

Hi @paolo.capitelli ,

Please see the answer from @Jeffrey_Risberg below. My answer below is not correct. Please disregard.

Have fun!

I have the same problem. Can you be more specific about changing to pytorch?

Thank you @c0d3junkie for your help.

Once I have installed pytorch do you know how I should I let the demo for the first lesson of this course work properly?

Thanks a lot

I have created a solution to the problem of getting the app to run on MacOS 14, Intel chip

I checked the dependencies that were causing torch to be needed. This was in sentencetransformers.

The sentencetransformers lib is only used as the embedding model for the vector database. So I took out sentencetransformers, and used OpenAI instead.

The changes are in vector_store.py, which now looks like:

import chromadb
from chromadb.config import Settings
from typing import List, Dict, Any, Optional
from dataclasses import dataclass
from models import Course, CourseChunk
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction

@dataclass
class SearchResults:
“”“Container for search results with metadata”“”
documents: List[str]
metadata: List[Dict[str, Any]]
distances: List[float]
error: Optional[str] = None

@classmethod
def from_chroma(cls, chroma_results: Dict) -> 'SearchResults':
    """Create SearchResults from ChromaDB query results"""
    return cls(
        documents=chroma_results\['documents'\]\[0\] if chroma_results\['documents'\] else \[\],
        metadata=chroma_results\['metadatas'\]\[0\] if chroma_results\['metadatas'\] else \[\],
        distances=chroma_results\['distances'\]\[0\] if chroma_results\['distances'\] else \[\]
    )

@classmethod
def empty(cls, error_msg: str) -> 'SearchResults':
    """Create empty results with error message"""
    return cls(documents=\[\], metadata=\[\], distances=\[\], error=error_msg)

def is_empty(self) -> bool:
    """Check if results are empty"""
    return len(self.documents) == 0

class VectorStore:
“”“Vector storage using ChromaDB for course content and metadata”“”

def \__init_\_(self, openai_api_key: str, chroma_path: str, max_results: int = 5):
    self.max_results = max_results
    # Initialize ChromaDB client
    self.client = chromadb.PersistentClient(
        path=chroma_path,
        settings=Settings(anonymized_telemetry=False)
    )

    self.embedding_function = OpenAIEmbeddingFunction(
        api_key=openai_api_key,
        model_name="text-embedding-3-small"
    )

    # Create collections for different types of data
    self.course_catalog = self.\_create_collection("course_catalog")  # Course titles/instructors
    self.course_content = self.\_create_collection("course_content")  # Actual course material

And the requirements specified in pyproject.py are now:

project

name = “starting-codebase”
version = “0.1.0”
description = “Add your description here”
readme = “README.md”
requires-python = “>=3.13”
dependencies = [
“chromadb==1.0.15”,
“anthropic”,
“openai”,
“fastapi==0.116.1”,
“uvicorn==0.35.0”,
“python-multipart==0.0.20”,
“python-dotenv==1.1.1”
]


-

You will need an openAI_API_KEY

Now the app is running for me, and I am proceeding with the course.

1 Like

Thank you very much for the effort in solving this problem.

I am quite newbie with python but I it seems to me that the method _create_collection is missing in your code. In fact I get an error message when I launch the ./run.sh script.

Thank you for your help

Ops sorry. I think I understood my mistake

The issue isn’t a question of torch vs PyTorch. The issue is the PyTorch no longer supports Intel-based Apple hardware and OS. See

Yes, I figured that out when I saw the reply from @Jeffrey_Risberg, I remember having to go through the logs for the sentencetransformers lib and trying to figure that out. Sorry to spread incorrect info. :frowning:

Thank you so much for the support Jeffrey!