Tensorflow < 2.4 chip M1 - python

I am working on a project which requirements need python 3.7 and TensorFlow 2.3.1. The problem, I have a MacBook Pro with M1 chip. I was able to install and run TF 2.4.
However, I am running into more complicated compatibility issues.
Does anyone know how can I solve this?

M1 has a compatibility issue with TensorFlow. There is a workaround provided by Apple and other blogs. I have recently tried the same and have provided the summary below:
Tensorflow:
OS: BigSur(11.2.3)
Install command-line tools:
xcode-select --install
Install miniforge:
https://github.com/conda-forge/miniforge#miniforge3
After download run
chmod +x ~/<dir>/Miniforge3-MacOSX-arm64.sh
sh ~/<dir>/Miniforge3-MacOSX-arm64.sh
dir: directory to which miniforge is downloaded.
Or
brew install miniforge
After download change source to miniforge3
source ~/miniforge3/bin/activate
Download the environment.yml file from
https://github.com/mwidjaja1/DSOnMacARM
Setup a new conda environment using the yml file:
conda env create --file=environment.yml --name env_name
conda activate env_name
Install tensorflow dependencies:
conda install -c apple tensorflow-deps
Install base tensorflow:
python -m pip install tensorflow-macos
Install tensorflow-metal plugin:
python -m pip install tensorflow-metal
Possible Issues:
Miniforge uses conda-forge to install packages
Method to route channel to conda-forge
conda install -c conda-forge matplotlib
conda install or pip install might not work
Packages available for libraries in conda-forge:
https://anaconda.org/conda-forge
Only these will work.
Sources:
https://developer.apple.com/metal/tensorflow-plugin/
https://towardsdatascience.com/installing-tensorflow-on-the-m1-mac-410bb36b776
https://github.com/mwidjaja1/DSOnMacARM

Related

'Expected in: /usr/lib/libc++.1.dylib': Installing Tensorflow on M1 MacBook Pro

I am trying to install Tensorflow on my MacBook Pro with the M1 chip. The operating system of my MacBook is MacOS Big Sur Version 11.0.
In order to install Tensorflow to use it with Python, I have followed this tutorial, which says that I have to do the following:
Install Homebrew.
Download MiniForge3 for macOS arm64 chips (link provided in the webpage).
Install MiniForge3 using:
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate
Create a folder to set up an environment for Tensorflow.
mkdir tensorflow-test
cd tensorflow-test
Make and activate Conda environment.
conda create --prefix ./env python=3.9.7
conda activate ./env
Install Tensorflow dependencies.
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
After this, I open a Jupyter Notebook and I try to import tensorflow, but this error shows up:
OSError: dlopen(/Users/blancoarnau/tensorflow-test/env/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so, 6): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
Referenced from: /Users/blancoarnau/tensorflow-test/env/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so (which was built for Mac OS X 12.3)
Expected in: /usr/lib/libc++.1.dylib
As you can see in this screenshot:
Do you have an idea why this is happening?
check the message details:
(which was built for Mac OS X 12.3)
you need to upgrade macOS to 12.3

How to run sklearn library with native tensorflow on m1 mac

I have installed TensorFlow using a virtual environment running python 3.8 as described by Apple. This should theoretically run natively and utilise the GPU. I tried installing TensorFlow using miniforge last time and it was not able to use the GPU as miniforge uses python 3.9 and Tensorflow for m1 macs currently require python 3.8.
On sklearns website, the only way to install sklearn libraries currently is by using conda install sklearn which is through miniforge.
Is there a way to install sklearn on a tensorflow environment created using
python3 -m venv TFGPU
I have already tried pip. I was able to install most other libraries other than sklearn which I use for pre-processing.
Hi and welcome to SO :)
I'm a pip/virtualvenv user, so I had to fix my venv to work with my M1 mac using the conda/miniforge, without switching to conda's venv. So, I believe this should work for you as well:
# if not yet installed
xcode-select --install
git clone git://github.com/scikit-learn/scikit-learn.git
cd scikit-learn
# mac / mac m1 specific
brew install libomp
brew install miniforge
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
conda init bash
conda create -n conda-sklearn-dev -c conda-forge python numpy scipy cython joblib threadpoolctl pytest compilers llvm-openmp
conda activate conda-sklearn-dev
pip install cython
pip install --verbose --no-build-isolation --editable .
Now:
Test it on the conda venv. You should get version 0.24.2 (at the
time of writing)
Deactivate all conda venv-s
Activate your regular venv and test again. you should get version .dev0
In case sklearn is missing - do a simple pip install for it - it should grab the compiled one

How do in install chempy on Linux using miniconda?

Tried to install chempy on Linux as described in the documentation:
conda create -n chempy python=3.9
conda activate chempy
conda install -c bjodah chempy pytest
This resulted in the following error message.
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- chempy -> python[version='2.7.*|3.5.*|3.6.*|3.4.*']
Switching to python version 3.6 didn't help either, as some packages explicitly demand 3.9 or higher.
System specification:
Operating system: Ubuntu 20.04.2 LTS
Miniconda version: 4.10.1
Python: 3.9
Unfortunately, the chempy conda package is not complete, nor is the pip package.
The only way it works seems to be to install dependencies manually from separate sources.
Install miniconda, create a separate environment and activate it:
conda create -n "chempy" python=3.9
conda activate chempy
Install dependencies
conda install -c anaconda boost
conda install -c conda-forge gsl
conda install -c conda-forge pycvodes
conda install -c conda-forge sundials
Now you can install chempy:
python3 -m pip install chempy[all]
Test your installation:
python3 -m pytest -rs -W \
ignore::chempy.ChemPyDeprecationWarning --pyargs \
chempy > test.out
The following tests will fail but chempy works nonetheless:
kinetics/tests/test__native.py FF..FFFFFF [ 3%]
...
util/tests/test_table.py ..FFF [100%]
System specification:
Operating systems: Ubuntu 20.04.2 LTS, Debian 10.9 (both 64-Bit-PC)
Miniconda version: 4.10.1
Python: 3.9
Note for Windows users:
Not all dependencies are available for Windows, so it's not possible to install chempy on Windows.
I recommend installing it in a virtual machine such as Virtual Box or wsl (not tested).

cannot install tensorflow on anaconda

i am trying to install tensorflow on anaconda
i tried conda install -c conda-forge tensorflow
but the installation stuck on Solving environment:
looked for a solution so someone suggested to install with debug
conda install --debug -c conda-forge tensorflow
but it stopped on
DEBUG conda.resolve:filter_group(277): tensorboard: pruned from 47 -> 0
how to fix this?
For python version 3.7, you need to first downgrade to 3.6 using conda install python=3.6. After that, the installation should work. I had a similar problem recently.
What it worked for me was:
I uninstalled old versions of python and anaconda from my PC.
I installed anaconda (Anaconda3-4.4.0-Windows-x86_64.sh) from here.
I confirmed the conda installation by: conda -V
It should give you: conda 4.3.21
I confirmed the python installation by: python -V
It should give you: Python 3.6.1 :: Anaconda 4.4.0 (64-bit)
Confirm the conda environment by typing on anaconda prompt:
conda update conda
conda update anaconda
Next, I Installed theano by: conda install theano
Next, I installed tensorflow by: conda install -c conda-forge tensorflow
Last, I installed keras by: pip install keras
This process takes some while.
The latest Tensorflow 1.12 supports python 3.4,3.5 or 3.6.
python 3.7 is not supported.
you can download Anaconda 5.2.0
After the Anaconda is installed, you can use conda install tensorflow or conda install tensorflow-gpu to quickly install tensorflow

Installing fbprophet Python on Windows 10

My build keeps failing on windows 10 for installing fbprophet in anaconda with the following message:
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::automat-0.7.0-py_1'.
CondaError: Cannot link a source that does not exist. C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\Scripts\conda.exe
the command that is given is:
conda install -c conda-forge fbprophet
Has anyone successfully installed fbprophet on Windows 10? If yes, then please give the steps.
Thanks.
I tried pip install as well but no luck. I have a Mac and managed to install fbprophet on it without any issues.
First install Anaconda or miniconda in your Windows machine and add conda python path to env variable as default python.
Open your command prompt and run following commands.
Create a conda virtual environment (optional)
conda create -n v-env python=3.7
activate v-env
Install c++ complier
conda install libpython m2w64-toolchain -c msys2
libpython will automatically create and setup distutils.cfg file for you in PYTHONPATH\Lib\distutils, but if that is failed use the following instructions to setup it manually
[OPTIONAL]
create distutils.cfg with text editor (e.g. notepad, notepad++) and add the following lines to that file.
[build]
compiler=mingw32
Install dependencies
conda install numpy cython -c conda-forge
conda install matplotlib scipy pandas -c conda-forge
Install PyStan
pip install pystan
or
conda install pystan -c conda-forge
Install Ephem
conda install -c anaconda ephem
Install fbprophet
pip install fbprophet
or
conda install -c conda-forge fbprophet
I also faced installing facebook prophet issue in windows 10 without conda.
But,we can solve it.
First, uninstall any pystan, fbprophet.
Then follow the steps below,
python.exe -m pip install pystan==2.17.1.0
python.exe -m pip install fbprophet==0.6
python.exe -m pip install --upgrade fbprophet
Thanks,
tsj
Updated: 28 July 2022
As of v1.0, the package name on PyPI is "prophet"; prior to v1.0 it was "fbprophet". fbprophet is now just prophet. A few additional considerations:
From v0.6 onwards, Python 2 is no longer supported.
As of v1.1, the minimum supported Python version is 3.7.
Below one will find how to
Install with PyPI
Install with Anaconda
Install the Development version
1. Istallation in Python using PyPI
Prophet is on PyPI, so one can use pip to install it.
python -m pip install prophet
2. Installation in Python using Anaconda
One might have to access Anaconda Prompt for the environment that one is working with as admin:
And run
conda-forge: conda install -c conda-forge prophet
Or
conda install -c conda-forge prophet -y
3. Development version
To get the latest code changes as they are merged, one can clone this repo and build from source manually. This is not guaranteed to be stable.
git clone https://github.com/facebook/prophet.git
cd prophet/python
python -m pip install -r requirements.txt
python setup.py develop
By default, Prophet will use a fixed version of cmdstan (downloading and installing it if necessary) to compile the model executables. If this is undesired and one would like to use one's existing cmdstan installation, one can set the environment variable PROPHET_REPACKAGE_CMDSTAN to False:
export PROPHET_REPACKAGE_CMDSTAN=False;
Sources
https://facebook.github.io/prophet/docs/installation.html
https://github.com/facebook/prophet
I've had the same problem. But it works after I follow this steps:
On Prompt install Ephem:
conda install -c anaconda ephem
Install Pystan:
conda install -c conda-forge pystan
Finally install Fbprophet
conda install -c conda-forge fbprophet
Latest installation code for 2021:
pip install pystan==2.19.1.1, then pip install prophet
Also, reboot your jupyter notebook after installation
Install without Conda, Win 10, Python 3.8.8 64 bit.
pip3 install Cython
Then install:
Reboot your maching
Install
pip3 install pystan==2.17.1.0
pip3 install fbprophet
Here's my solution. I have not use conda-forge before, so reading up on this article helps.
Making sure that conda is ≥4.9
conda --version
add conda forge channel
conda config --add channels conda-forge
conda --set channel_priority strict
install gcc
conda install gcc
install prophet
conda install -c conda-forge prophet
I used the prophet documentation here
I faced the same issue and my solution was to:-
Create a new environment with Python3.5
conda create -n pht python=3.5 anaconda
Install Prophet using the command.
conda install -c conda-forge fbprophet
I didn't install 'gcc' although this was advised before installing Prophet.
I am using Python 3.8.5 and conda 4.10.1 on a Windows 10 machine.
I was able to install prophet in Anaconda 2.0.1 using command prompt (not as admin), using: conda install -c conda-forge fbprophet
It took some time for it to figure out the details, as you can see from the prompts below, but finally it was able to install the package.
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: done

Categories

Resources