There are a lot of steps here but they're very straightfoward. I pulled my AMD card out this afternoon after work, installed the Nvidia GPU, and had Deep Dream up and running in a short time. Take your time, explicitly follow each step, and you should be good to go. I'm running Linux Mint 17, which is built from Ubuntu 14.04 LTS. I'm also working with Python 2.7. If you are on a different version then change the file path for caffe accordingly.
THIS PART IS ONLY NECESSARY IF YOU HAVE A COMPATIBLE GPU. IF NOT GO TO "INSTALLING CAFFE"
You will need an Nvidia GPU with compute capability >=3.0. I will post instructions on cuDNN installation tomorrow. In the meantime you can see if your GPU will work here - https://en.wikipedia.org/wiki/CUDA#Supported_GPUs
INSTALLING CUDA 7.0 and NVIDIA DRIVERS
Pull up terminal and issue the following commands:
sudo apt-get --purge remove nvidia*
sudo su
echo nouveau >> /etc/modprobe.d/blacklist.conf
cd ~/Downloads
mkdir nvidia_installer
cd nvidia_installer
wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x cuda_7.0.28_linux.run
./cuda_7.0.28_linux.run -extract=~/Downloads/nvidia_installer
Time to disable the Nouveau driver to install the Nvidia drivers
sudo gedit /etc/default/grub
Edit to to reflect this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"
Reboot
Ctrl+Alt+F1 to go to terminal screen
Issue these commands:
sudo service mdm stop
sudo init 3
cd ~/Downloads/nvidia_installer
sudo ./NVIDIA-Linux-x86_64-346.46.run
sudo modprobe nvidia
sudo ./cuda-linux64-rel-7.0.28-19326674.run
sudo ./cuda-samples-linux-7.0.28-19326674.run
sudo init 5
sudo service mdm start
Ctrl+Alt+F7 to get back to graphical window. Pull up terminal
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
sudo ./deviceQuery
You should see something similar to this - CLICK
INSTALLING CAFFE - SEE NEXT STEP FOR MULTICORE SUPPORT (READ THAT FIRST)
This was the most difficult part but I think I've ironed out any bumps you might hit.
sudo apt-get install build-essential git
cd ~
git clone https://github.com/BVLC/caffe.git
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev python python-dev python-scipy python-setuptools python-numpy python-pip libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler libatlas-dev libatlas-base-dev libatlas3-base libatlas-test
sudo apt-get install --no-install-recommends libboost-all-dev
sudo pip install --upgrade pip
sudo pip install --upgrade numpy
cd ~/caffe
cp Makefile.config.example Makefile.config
If you want to use cudNN, you will need to register with Nvidia and make the following change to Makefile.config: Uncomment
USE_CUDNN := 1
Back to the install: If you're not using CUDA, then you'll want CPU only mode. Edit Makefile.config and uncomment
CPU_ONLY := 1
I'm sure some of this is redundant, but you will need to add these to ~/.bashrc
export PATH=$PATH:/usr/local/cuda-7.0/bin
export LD_LIBRARY_PATH=:/usr/local/cuda-7.0/lib64
export PYTHONPATH="${PYTHONPATH}:/home/USERNAME/caffe/python"
export PATH=/usr/local/cuda/bin:${PATH}
PATH=${CUDA_HOME}/bin:${PATH}
export PATH
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=:/usr/local/cuda/lib64
You will substitute X for the number of cores in your machine.
source ~/.bashrc
make all -jx
make test -jx
make runtest -jx
make pycaffe -jx
CAFFE WITH MULTICORE SUPPORT
If you have multiple cores, which you probably do because it's 2015, and you have access to the Intel MKL, then you can build caffe to make use of every core. In these directions I'm assuming you've installed the MKL (If you're installing MKL and it gives you an error about an unsupported OS just continue, it works). I am also assuming you don't want to/can't use your GPU.
cd ~/caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config
Uncomment line 8 that says
CPU_ONLY := 1
Change line 33 to
BLAS := mkl
Uncomment lines 37 and 38 and add the path to your mkl include and lib directories. I installed composerXE so my lines 37 and 38 look like this
BLAS_INCLUDE := /opt/intel/composer_xe_2011_sp1.10.319/mkl/include
BLAS_LIB := /opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64
Again, use the path to your mkl lib directory here
sudo ldconfig /opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/
After that follow the directions above starting with the section on editing ~/.bashrc
RUNNING DEEP DREAM
cd ~
git clone https://github.com/google/deepdream.git
wget -P ~/caffe/models/bvlc_googlenet http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel
cd ~/deepdream
ipython notebook ./dream.ipynb
Click inside each body of code and hit the play button. Wait and watch as your computer displays its deepest thoughts.
PASTEBIN RAW
Deep dream python script with loop - http://pastebin.com/1ePNC89A
来源:oschina
链接:https://my.oschina.net/u/2306127/blog/629965