gpu mac 环境搭建 - wanghaisheng/awesome-ocr GitHub Wiki
http://blog.wenhaolee.com/run-keras-on-mac-os-with-gpu/
http://daoyuan.li/installing-theano-and-cuda-on-mac-os-x/
http://hoondy.com/2015/04/03/how-to-install-caffe-on-mac-os-x-10-10-for-dummies-like-me/
http://www.pyimagesearch.com/2014/10/06/experience-cudamat-deep-belief-networks-python/
https://github.com/tensorflow/tensorflow/issues/491
问题1
➜ examples git:(master) sudo pip install keras
Password:
The directory '/Users/wanghaisheng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/wanghaisheng/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): keras in /usr/local/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): theano in /usr/local/lib/python3.5/site-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /usr/local/lib/python3.5/site-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python3.5/site-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.1 in /usr/local/lib/python3.5/site-packages (from theano->keras)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.11 in /usr/local/lib/python3.5/site-packages (from theano->keras)
➜ examples git:(master) sudo pip install Theano --user
The directory '/Users/wanghaisheng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/wanghaisheng/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): Theano in /usr/local/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.1 in /usr/local/lib/python3.5/site-packages (from Theano)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.11 in /usr/local/lib/python3.5/site-packages (from Theano)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in /usr/local/lib/python3.5/site-packages (from Theano)
➜ examples git:(master) THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python imdb_cnn.py
Traceback (most recent call last):
File "imdb_cnn.py", line 13, in <module>
from keras.preprocessing import sequence
ImportError: No module named keras.preprocessing
➜ examples git:(master) THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python3 imdb_cnn.py
Using Theano backend.
ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.
Loading data...
Downloading data from https://s3.amazonaws.com/text-datasets/imdb.pkl
319488/33213513 [..............................] - ETA: 12264s
问题2
➜ bin ./nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Thu_Sep_24_00:26:39_CDT_2015
Cuda compilation tools, release 7.5, V7.5.19
nvcc fatal : The version ('70300') of the host compiler ('Apple clang') is not supported
➜ bin clang -v
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
解决方案 https://github.com/arrayfire/arrayfire/issues/1384 https://gist.github.com/zchee/7833bf67013e83523181 http://blog.cgfm.jp/garyu/archives/3314 stackoverflow.com/questions/36250949/revert-apple-clang-version-for-nvcc http://makeclean.iobloggo.com/479/apple-clang-730-osx-10114-and-cuda-sdk-7520-problem/&cid=100891
经确认是CUDA版本太低 ➜ cuda git:(master) ls CUDA_Toolkit_Release_Notes.txt lib64 EULA.txt libnsight bin libnvvp doc nvvm extras samples include src jre tools lib version.txt ➜ cuda git:(master) cat version.txt CUDA Version 7.5.19
安装了cuda7.5.27 问题解决
问题3
➜ examples git:(master) THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python3 imdb_cnn.py
Using Theano backend.
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: Unable to get the number of gpus available: CUDA driver version is insufficient for CUDA runtime version)
➜ bin ./nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Mon_Apr_11_13:23:40_CDT_2016
Cuda compilation tools, release 7.5, V7.5.26
下载新的驱动 http://www.nvidia.com/object/mac-driver-archive.html http://www.nvidia.com/object/macosx-cuda-7.5.30-driver.html
New Release 7.5.30
CUDA driver update to support MAC OS X 10.11.5, macOS 10.12 Developer Preview and NVIDIA display driver 346.03.10f01
Recommended CUDA version(s):
CUDA 7.5
Supported MAC OS X
10.11.x
10.10.x
https://github.com/torch/cutorch/issues/435 http://blog.csdn.net/qianqing13579/article/details/51164463
说明CUDA版本不支持显卡 解决方案: 1. 安装显卡驱动 2.安装低版本的CUDA
历史版本下载地址 https://developer.nvidia.com/cuda-toolkit-archive
0803晚上尝试
➜ examples git:(master) THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python3 imdb_cnn.py
Using Theano backend.
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: Unable to get the number of gpus available: CUDA driver version is insufficient for CUDA runtime version)
Loading data...
Downloading data from https://s3.amazonaws.com/text-datasets/imdb.pkl
33202176/33213513 [============================>.] - ETA: 0s20000 train sequences
5000 test sequences
Pad sequences (samples x time)
X_train shape: (20000, 400)
X_test shape: (5000, 400)
Build model...
Train on 20000 samples, validate on 5000 samples
Epoch 1/2
20000/20000 [==============================] - 77s - loss: 0.4516 - acc: 0.7715 - val_loss: 0.3068 - val_acc: 0.8712
Epoch 2/2
20000/20000 [==============================] - 75s - loss: 0.2882 - acc: 0.8825 - val_loss: 0.2885 - val_acc: 0.8752
➜ examples git:(master) THEANO_FLAGS=mode=FAST_RUN python3 imdb_cnn.py
Using Theano backend.
Loading data...
20000 train sequences
5000 test sequences
Pad sequences (samples x time)
X_train shape: (20000, 400)
X_test shape: (5000, 400)
Build model...
Train on 20000 samples, validate on 5000 samples
Epoch 1/2
20000/20000 [==============================] - 85s - loss: 0.4516 - acc: 0.7715 - val_loss: 0.3068 - val_acc: 0.8712
Epoch 2/2
20000/20000 [==============================] - 101s - loss: 0.2882 - acc: 0.8825 - val_loss: 0.2885 - val_acc: 0.8752
最终该问题在尝试了所有CUDA 6.5 7.0 7.5 8.0 之后 才从 http://developer.download.nvidia.com/compute/cuda/8.0/secure/rc1/docs/sidebar/CUDA_Installation_Guide_Mac.pdf?autho=1470325753_bab3e22698b5fa610bf8eef8b604c712&file=CUDA_Installation_Guide_Mac.pdf 找到原因 xcode没有安装
卸载之前的安装
➜ local git:(master) sudo rm -r cuda
➜ local git:(master) cd /Library/Frameworks
➜ Frameworks ls
AEProfiling.framework NyxAudioAnalysis.framework
AERegistration.framework PluginManager.framework
AudioMixEngine.framework R.framework
CUDA.framework iTunesLibrary.framework
GTK+.framework
➜ Frameworks sudo rm -r CUDA.framework
➜ release sudo rm -r /Developer/NVIDIA
CUDA Driver:
rm -r /usr/local/cuda rm -r /Library/Frameworks/CUDA.framework
CUDA Toolkit:
rm -r /Developer/NVIDIA