macOS Big Sur安裝TensorFlow踩坑記
阿新 • • 發佈:2020-12-27
一,還是設定代理:
export http_proxy=http://192.168.31.168:1190 export https_proxy=http://192.168.31.168:1190二、通過下面的命令安裝 pip 和 Virtualenv:
$ sudo easy_install pip
$ pip install --upgrade virtualenv
裝完提示:
WARNING: The script virtualenv is installed in '/Users/meetrice/Library/Python/2.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. 根據提示加入環境變數吧 export PATH="$PATH:/Users/meetrice/Library/Python/2.7/bin" 三、執行下面的命令來建立 Virtualenv 環境(targetDirectory)$ pip install --upgrade tensorflow # 對應 Python 2.7
(targetDirectory)$ pip3 install --upgrade tensorflow # 對應 Python 3.n
五,驗證tensorFlow,執行HelloWorld
在虛擬環境中的當前目錄,建立helloworld.py
(targetDirectory) meetrice@mbp targetDirectory % nano helloworld.py 在編輯介面輸入以下內容:import tensorflow as tf
msg = tf.constant('Hello, TensorFlow!')
tf.print(msg)
然後ctrl+x Y,回車儲存
然後執行
python helloworld.py
出現結果:
2020-12-27 14:34:26.911207: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices n
ot set
2020-12-27 14:34:26.918930: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI
Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Hello, TensorFlow!
HelloWorld 成功!