Tensorflow deployed in Gamestonk Terminal:
If you are one of the many users working with the new generation of CPU/GPU chips in the various Mac computers, you might have run into compatibility issues when attempting to utilize Tensorflow. There are lots of questions online about how to make Tensforflow work on M1 machines, and finally I’m happy to say that I have a solution for machines running Mac OS 11.6.2 or later, regardless of CPU/GPU architecture.
Illegal Operation: 4
That was the error I was getting for months as I tried all the tutorials I could find on this known issue. Nothing was working and it was getting pretty frustrating, but finally I received a tip that set me on the right path. It all starts with your virtual environment handler.
There were many suggestions across the Internet to use MiniConda3, however they all failed to highlight the need to download a very specific version. While there is a version built exclusively for the M1 architecture, what is not obvious is, Tensorflow does not work with the M1 version of MiniConda, Anaconda, Docker, etc.
Through all my tinkering, the only way to successfully run Tensorflow on any Mac machine has been with the x86_64 version for Python 3.9.
If not installing Miniconda in a newly sandboxed environment, uninstall any previous versions of Anaconda or Miniconda before continuing. This is compatible with legacy Mac Pro 3,1 towers and M1 machines.
The only other caveat is that the source for the Tensorflow package matters, and the silver bullet is through the source/command: conda install -c conda-forge tensorflow
Installing Tensorflow 2.7 on M1 & Mac Pro 3,1 Towers:
One incredible feature in the Gamestonk Terminal package is the ability to import any CSV file for plotting or, quantitative and predictive analysis. This provides a low-friction entry point into Tensorflow for anyone, not just stock market weirdos.
The best part is that Gamestonk Terminal is completely free and MIT Open Source licensed. The installation process is not basic, but it is simple to follow instructions, so I have included the short process below:
Sign up for a GitHub account. If you haven’t already, it’s free. Go to the project:
https://github.com/GamestonkTerminal/GamestonkTerminal — give it a star.
Install MiniConda3 using this version:
Open a terminal window and verify the installation: conda -V
Copy and paste into the command prompt, selecting yes when prompted: conda install -c anaconda git
Navigate to a folder such as /Users and copy and paste: git clone https://github.com/GamestonkTerminal/GamestonkTerminal.git
Navigate into the cloned project folder: cd GamestonkTerminal/
Copy and paste into the command line: conda env create -n gst — file build/conda/conda-3–8-env.yaml
When finished, enter: conda activate gst
Then enter: poetry install
Install Tensorflow: conda install -c conda-forge tensorflow
Ready to run: python terminal.py
A successful installation of Gamestonk Terminal will require over 2GB of free disk space.
To get to the Tensorflow features, navigate to the stocks menu and load a ticker for analysis.
The stocks menu in Gamestonk Terminal:
The prediction menu and the options available for a Recurrent Neural Network engine:
A sample output using SPY daily close price
Loading a custom CSV file locally
Detecting abrupt changes using cumulative sum algorithm of prices (https://gamestonkterminal.github.io/GamestonkTerminal/terminal/common/quantitative_analysis/cusum/):
While not a requirement, acquiring individual API keys will take full advantage of the large feature sets within the Gamestonk Terminal suite. These keys must be obtained by the individual user for some features to function. The list of APIs used and the links to acquire them for free are found near the bottom of the installation instructions on GitHub: https://github.com/GamestonkTerminal/GamestonkTerminal
API keys used to retrieve data from a variety of sources:
The keys can be tested by navigating to /keys
The maintainers of this project provide great tech support for those in need. Any questions at all can be directed to the Discord server where a friendly member of the community is happy to help and discuss:
Follow Gamestonk Terminal on Twitter:
Thanks for reading, I hope this helps those struggling with Tensorflow and M1 compatibility problems.