# Conda environment for TensorFlow and ROOT(HEP) in Mac

# Conda environment for TensorFlow and ROOT(HEP) in Mac ,第1张

Follow the procedures described below:

清除原有xcode环境 (for ROOT installation)

  1. remove xcode(卸载干净)

  2. sudo rm -rf /Library/Developer/CommandLineTools

安装标准系统环境

  1. install xcode 13.0 (13A233)

  2.     alternatively(to save space),  xcode-select --install

#install conda

  1. chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh

  2. sh ~/Downloads/Miniforge3-MacOSX-arm64.sh

  3. source ~/miniforge3/bin/activate

#Install common data science packages.

  1. conda install -c conda-forge jupyter pandas numpy matplotlib scikit-learn

  2. conda install -c conda-forge scipy sympy h5py mplhep tqdm

#install M1 tensorflow (Tensorflow Plugin - Metal - Apple Developer)

  1. conda create --name TF_env python=3.9 # creat a new conda env

  2. conda install -c apple tensorflow-deps # Install the TensorFlow dependencies

  3. python -m pip install tensorflow-macos # Install base TensorFlow

  4. python -m pip install tensorflow-metal # Install tensorflow-metal plugin

  5. python -m pip install tensorflow-datasets # (optional) Install TensorFlow Datasets

#install ROOT (Installing ROOT - ROOT)

  1. conda create --name ROOT_env python=3.9 # creat a new conda env

  2. 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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/563899.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-03
下一篇 2022-04-03

发表评论

登录后才能评论

评论列表(0条)

保存