Install PyTorch on Apple Silicon Macs (M1, M2, M3) and Check for MPS Availability in 2024

Поділитися
Вставка
  • Опубліковано 6 лис 2024

КОМЕНТАРІ • 14

  • @miltondossantos9876
    @miltondossantos9876 2 місяці тому +1

    Thanks Sir.

  • @shyam2469
    @shyam2469 Місяць тому +1

    what is need for installing Xcode ? can't we install pytorch without that ?

    • @DrDataScience
      @DrDataScience  Місяць тому

      Some PyTorch installation methods (especially if you're building from source or dealing with certain dependencies) might require Xcode's Command Line Tools. These tools include compilers and other utilities needed to build software from its source code.

  • @thinhtran-fd1yd
    @thinhtran-fd1yd 25 днів тому

    i using comfyUI and it notification "MPS backend out of memory".Can you help me fix error ?

  • @janyajoshi
    @janyajoshi Місяць тому +1

    I see this mps available, but still get CUDA error
    AssertionError: Torch not compiled with CUDA enabled

    • @DrDataScience
      @DrDataScience  Місяць тому

      Good question! CUDA is NVIDIA's parallel computing platform and API that enables GPUs to significantly accelerate computations. While your Mac has the MPS (Metal Performance Shaders) backend for hardware acceleration, it doesn't inherently support CUDA.

    • @MGeezus-s2b
      @MGeezus-s2b 2 дні тому

      tensor.to('mps') if torch.backends.mps.is_available() and torch.backends.mps.is_built()

  • @estebann
    @estebann 3 місяці тому +1

    For some reason I can only see and install pytorch 2.2.2 as latest. I am on same python version, Sonoma 14.5, M3 24gb.

    • @DrDataScience
      @DrDataScience  3 місяці тому

      Interesting! I checked the PyTorch website again and the last version is 2.4, which was released on July 24: github.com/pytorch/pytorch/releases/tag/v2.4.0

    • @estebann
      @estebann 3 місяці тому

      @@DrDataScience yes! I am having a weird issue, the python thwt i am getting installed is for x86_64 , I cannot get brew to install the arm64 version, so for x86_64 with rosetta, only 2.2.2 is available

    • @estebann
      @estebann 3 місяці тому

      @@DrDataScience I was able to solve this. For some reason brew kept on installing x86_64 version of python, which only has support up to the 2.2.2 pytorch version. I was able to force reinstall brew, and force every install the arm64 version with the "arch --arm64" command. Then I was able to have python compatible with 2.4 version of pytorch.

    • @blademeng5368
      @blademeng5368 Місяць тому

      @@estebann Hi, I got same problem. Already upgrade the brew to latest one, but still can only install 2.2.2 pytorch version. I have downloaded the latest 2.4.1 torch from web, and try to install it by "pip install torch-2.4.1-****.whl", unfortunately it says: ERROR: torch-2.4.1-cp39-none-macosx_11_0_arm64.whl is not a supported wheel on this platform. Not sure why. My MBP is based on M3 sillion.

    • @estebann
      @estebann Місяць тому

      ​@@blademeng5368 I spent a couple of hours trying to reinstall brew. I would insist you using "arch --arm64" to force using the ARM version of everything from brew to python. That was the only way. That you can only get 2.2.2 is a tell-tell sign that you are having the exact same issue and for some reason only trying to install x64_64 , for which at this moment the latest version is 2.2.2