TensorFlow的安裝分為支持GPU和不支持GPU兩種拜轨。但每種安裝方式有好多種,這里只介紹最簡(jiǎn)單的支持GPU的安裝允青。
一橄碾、是否支持GPU
查看NVIDIA documentation對(duì)應(yīng)mac上的GPU型號(hào),如果兼容性在3.0以及以上則『是』,否則『否』法牲。
二史汗、檢查和升級(jí)
1.mac osx是否是10.11以及以上,如果不是拒垃,請(qǐng)升級(jí)停撞;
2.xcode是否是7.3以及以上,如果不是悼瓮,請(qǐng)升級(jí)戈毒;
三、安裝NVIDIA相關(guān)驅(qū)動(dòng)
1.CUDA Toolkit 8.0. For details, seeNVIDIA's documentation.?
step1:從Download下載横堡,并安裝;
step2:export PATH="/Developer/NVIDIA/CUDA-8.0.61/bin:$PATH"
step3:export DYLD_LIBRARY_PATH="/Developer/NVIDIA/CUDA-8.0.61/lib:$DYLD_LIBRARY_PATH"
2.cuDNN v5.1. For details, seeNVIDIA's documentation.?
step1:從Download下載cuDNN v6.0
step2:tar xzvf /path_to/cudnn-8.0-osx-x64-v5.1.tgz -C /target_path
step3:cd /target_path/cuda
step4:export DYLD_LIBRARY_PATH=`pwd`:$DYLD_LIBRARY_PATH
3.安裝TensorFlow
step1:sudo easy_install pip
step2:pip install --upgrade tensorflow-gpu(如果失敗埋市,嘗試執(zhí)行step4)
step3:如果step2失敗,執(zhí)行step4
step4:pip install --upgrade https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-1.0.1-py2-none-any.whl (如果失敗命贴,嘗試執(zhí)行step5)
step5:sudo -H pip install https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-1.0.1-py2-none-any.whl --upgrade --ignore-installed
4.關(guān)掉SIP(Security Integrity Protection)
step1:按住comand+R道宅,同時(shí)按住電源鍵;當(dāng)出現(xiàn)蘋果logo的時(shí)候套么,松開電源鍵
step2:等待出現(xiàn)系統(tǒng)工具窗口
step3:選擇工具-->終端培己,然后輸入:csrutil disable
step4:選擇蘋果圖標(biāo)-->重啟
5.驗(yàn)證TensorFlow是否安裝成功
? ? ? ? ? ? ?終端輸入:python -c 'import tensorflow as tf'