Tensor Flow for M1 chip pro & VS code

Hello all

I have bought a new MacBook pro (14-inch 2021) -- M1 chip pro.

I am trying to run a python code on Visual Studio code, but it requires tensor flow.

I have followed the following forum (https://developer.apple.com/metal/tensorflow-plugin/)

But note that its all the steps were okay, except for tensorflow-deps versions are following base TensorFlow versions so:

For v2.5: conda install -c apple tensorflow-deps==2.5.0 For v2.6:

conda install -c apple tensorflow-deps==2.6.0

it provides the error::

conda install -c apple tensorflow-deps==2.6.0 Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: -  Found conflicts! Looking for incompatible packages. This can take several minutes.  Press CTRL-C to abort. failed                                                                                                                                                                UnsatisfiableError: The following specifications were found to be incompatible with each other: Output in format: Requested package -> Available versions

I ignored the error and I have rerun the python code, but the same error pops up:

import tensorflow as tf ModuleNotFoundError: No module named 'tensorflow'

So any help please

Answered by daliasobhi in 728990022

Yeah I got it and followed ur suggestions — but I have another question once I try to just write import tensorflow as tf in visual studio code and run it as a python file. It says no module named tensorflow.

However, when I run the same line in terminal it works so any idea how to solve this?

thanks a million

Hello @dialiasobhi,

Any particular reason you want to install v2.6? We recommend installing the latest available packages to get recent fixes and improvements.

To install the latest on Apple Silicon:

  • Download and install Conda env
source ~/miniforge3/bin/activate
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
Accepted Answer

Yeah I got it and followed ur suggestions — but I have another question once I try to just write import tensorflow as tf in visual studio code and run it as a python file. It says no module named tensorflow.

However, when I run the same line in terminal it works so any idea how to solve this?

thanks a million

Tensor Flow for M1 chip pro & VS code
 
 
Q