I am currently reading Deep Learning with TensorFlow and Keras to get started with Machine Learning/Deep Learning. Here is how I setup a local Keras/Tensorflow 2.0 environment on my M1 Max MacBook Pro running macOS 12.6.
Install miniconda.
|
|
I use zsh with iTerm2 as my terminal so I need to initialize conda with the following command.
|
|
This will make it so everytime iTerm2 is opened, the conda base environment will be activated. I prefer to activate my environment manually, so I did the below to deactivate the base environment on launch of iTerm2.
In ~/.zshrc
add the following section after the # <<< conda initialize <<<
line.
|
|
We now create an environment named tensorflow where we could run our ML/DL Keras training.
|
|
We then switch to the tensorflow environment and install dependencies.
|
|
This may not be necessary for future installs. But I ran into an error with numpy when trying to run my notebook code.
module compiled against API version 0x10 but this version of numpy is 0xf
To correct this I had to run this command in my tensorflow environment.
|
|
Another warning I ran into.
TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .autonotebook import tqdm as notebook_tqdm
To resolve I ran the below in my tensorflow environment.
|
|
You may now run jupyter notebook
command from the tensorflow environment to start the jupyter notebook environment from the command line. I however prefer using Visual Studio Code and start an environment under vscode as documented below.
- Install the
Jupyter
extension under vscode. - Load the Command Pallet using (
Cmd+Shift+P
) and selectJupyter: Select Interpreter to Start Jupyter Server
and then selectPython 3.9.13 ('tensorflow')
or whatever environment you want to use. - Load the Command Pallet using (
Cmd+Shift+P
) and selectCreate: New Jupyter Notebook
- You may now run all the Jupyter notebook in vscode. When run the code cell, vscode will start the jupyter server if it is not already started in the selected environment.
Code
|
|
Output
|
|