[Python] How to install TensorFlow 2.16 on Macbook Pro M2?

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I currently use TensorFlow 2.13.1 (tensorflow-macos) with TF-metal (1.0.0). I want to migrate to TensorFlow 2.16.1 to keep up with the updates.

    In the update website, they say the following:


    Apple Silicon

    If you previously installed TensorFlow using pip install tensorflow-macos, please update your installation method. Use pip install tensorflow from now on. tensorflow-macos package will no longer receive updates. Future updates will be released to tensorflow.
    ​

    That sounds great, but I have a few questions:

    1. Do I need to install tensorflow-metal for GPU acceleration? It doesn't seem to be possible.
    2. Is it stable?

    My tests so far have been unsuccessful.

    1. It keeps asking for Keras, even though it is installed.
    2. When I solved the Keras issue, a simple NN worked well. However, a simple GAN makes my Jupyter Notebook kernel die consistently.

    My computer is a 2023 Macbook Pro with an M2 Max chip. The OS is up-to-date.

    Do you have any suggestions as to what may be going on? Is there a better way to perform this update?

    Here are the specs for the environment that seems to work best for my machine:

    conda create -n myenv python=3.9.18
    conda activate myenv
    conda install -c apple tensorflow-deps
    pip install matplotlib==3.7.4
    pip install numpy==1.24.3
    pip install pandas==2.1.4
    pip install scipy==1.11.4
    pip install typing-extensions==4.5.0
    pip install seaborn==0.13.0
    pip install tensorflow-macos==2.13.1
    pip install tensorflow-metal==1.0.0
    pip install plotly==5.17.0
    pip install scikit-learn pyarrow
    conda install -c conda-forge notebook
    conda install ipykernel
    python -m ipykernel install --user --name=myenv --display-name "Python (myenv)"


    Here is the most general spec for the update:

    conda create -n myenv python==3.11.9
    conda activate myenv
    conda install matplotlib
    conda install numpy
    conda install pandas
    conda install scipy
    conda install typing-extensions
    conda install seaborn
    conda install tensorflow
    conda install plotly
    conda install scikit-learn pyarrow
    conda install -c conda-forge notebook
    conda install ipykernel
    python -m ipykernel install --user --name=myenv --display-name "Python (myenv)"


    I tried mix-and-match pip with conda (when appropriate) and also tried to change versions of packages to see if that would be the issue, but no success.

    Continue reading...

Compartilhe esta Página