Follow the procedures described below:
清除原有xcode环境 (for ROOT installation)
remove xcode(卸载干净)
sudo rm -rf /Library/Developer/CommandLineTools
安装标准系统环境
install xcode 13.0 (13A233)
alternatively(to save space), xcode-select --install
#install conda
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate
#Install common data science packages.
conda install -c conda-forge jupyter pandas numpy matplotlib scikit-learn
conda install -c conda-forge scipy sympy h5py mplhep tqdm
#install M1 tensorflow (Tensorflow Plugin - Metal - Apple Developer)
conda create --name TF_env python=3.9 # creat a new conda env
conda install -c apple tensorflow-deps # Install the TensorFlow dependencies
python -m pip install tensorflow-macos # Install base TensorFlow
python -m pip install tensorflow-metal # Install tensorflow-metal plugin
python -m pip install tensorflow-datasets # (optional) Install TensorFlow Datasets
#install ROOT (Installing ROOT - ROOT)
conda create --name ROOT_env python=3.9 # creat a new conda env
conda install root -c conda-forge
Start Jupyter Notebook.
jupyter notebook
root --notebook (could also use root-based notebook instead)
Test:
# M1 tensorflow # 测试 tensorflow 是否安装成功:
# test1.
import tensorflow as tf
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant('hello,tensorflow')
sess= tf.compat.v1.Session() #版本2.0的函数
print(sess.run(hello))
# test2.
import numpy as np
import pandas as pd
import sklearn
import tensorflow as tf
import matplotlib.pyplot as plt # Check for TensorFlow GPU access
print(f"TensorFlow has access to the following devices:\n{tf.config.list_physical_devices()}") # See TensorFlow version
print(f"TensorFlow version: {tf.version}")
==> If it all worked, you should see something like:
TensorFlow has access to the following devices: [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] TensorFlow version: 2.8.0
reference
Tensorflow Plugin - Metal - Apple Developer
How to Setup TensorFlow on Apple M1 Pro and M1 Max (works for M1 too)
Installing ROOT - ROOT
Root :: Anaconda.org Hep Ml :: Anaconda.org
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)