Ubuntu14.04 Install GeForce GTX 750 Ti for Deep Learning
2016-01-19 21:49
676 查看
Setting up an optimized GPU instance for Deep Learning using Theano on Amazon EC2 or a Linux Box with NVIDIA GPUs
This is a quick run-through of what is required to setup a GPU-based installation of Theano which can be done either on an AWS Grid instance or on a computer with a suitable NVIDIA GPU that supports CUDA for computation. In this tutorial we will brieflyrun through installation of Cuda 7.5, CuDNN 7.0, Theano 0.7 and Keras. We will finally test out our installation by running a Deeplearning training instance on the well known MNIST dataset using an example from Keras and ensure that we have relatively fast
training. We are going to use Ubuntu 14.04 in this post because I found 15.04 to be unstable on my Laptop at this time.
Start off by installing Ubuntu 14.04. Then update it and install essential build tools like so
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential git vim python-pip python3-pip liblapack-dev cython cython3 gfortran
1 2 | sudoapt-getupdate&&sudoapt-getupgrade sudo apt-getinstallbuild-essentialgitvimpython-pippython3-pipliblapack-devcythoncython3 gfortran |
sudo pip3 install numpy
sudo pip3 install scipy
1 2 | sudopip3install numpy sudo pip3 installscipy |
versions of Python repeat the process with the other pip version.
Now, let us try to install NVIDIA’s CUDA via the run-file. It can usually be foundhere and is slightly over 1 GB in size. This will download CUDA 7.5 provided the link
still works:
wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run
1 | wgethttp://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run |
chmod a+x cuda_7.5.18_linux.run
mkdir cuda_installer
./cuda_7.5.18_linux.run -extract=`pwd`/cuda_installer
rm cuda_7.5.18_linux.run
1 2 3 4 | chmoda+xcuda_7.5.18_linux.run mkdir cuda_installer ./cuda_7.5.18_linux.run-extract=`pwd`/cuda_installer rm cuda_7.5.18_linux.run |
sudo apt-get remove lightdm
sudo reboot
1 2 | sudoapt-getremovelightdm sudo reboot |
sudo apt-get install linux-image-extra-virtual
1 | sudoapt-getinstalllinux-image-extra-virtual |
sudo vi /etc/modprobe.d/blacklist-nouveau.conf
1 | sudovi/etc/modprobe.d/blacklist-nouveau.conf |
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
1 2 3 4 5 | blacklistnouveau blacklist lbm-nouveau optionsnouveaumodeset=0 alias nouveauoff aliaslbm-nouveauoff |
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
sudo reboot
1 2 3 | echooptionsnouveau modeset=0|sudotee-a/etc/modprobe.d/nouveau-kms.conf sudo update-initramfs-u sudoreboot |
sudo apt-get install linux-source
sudo apt-get install linux-headers-`uname -r`
1 2 | sudoapt-getinstalllinux-source sudo apt-getinstalllinux-headers-`uname-r` |
cd cuda_installer
sudo ./NVIDIA_Linux-x86_64-352.39.run
1 2 | cdcuda_installer sudo ./NVIDIA_Linux-x86_64-352.39.run |
end only if you’re going to be running X. On Amazon AWS EC2 instances select “no”. Once installed, you should be able to use:
nvidia-smi
1 | nvidia-smi |
sudo modprobe nvidia
sudo ./cuda-linux64-rel-7.5.18-19867135.run
sudo ./cuda-samples-linux-7.5.18-19867135.run
1 2 3 | sudomodprobenvidia sudo ./cuda-linux64-rel-7.5.18-19867135.run sudo./cuda-samples-linux-7.5.18-19867135.run |
Now we want to add CUDA to our path and library paths so CUDA can be compiled again easily. This can easily be done by adding the following lines to the ~/.bashrc file in your home-directory.
export PATH=$PATH:/usr/local/cuda-7.5/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64
1 2 | exportPATH=$PATH:/usr/local/cuda-7.5/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64 |
sudo apt-get install lightdm
sudo reboot
1 2 | sudoapt-getinstalllightdm sudo reboot |
to get it. The current version is cudnn-7.0. To install CuDNN use the following steps:
tar -xzvf cudnn-7.0-linux-x64-v3.0-prod.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
1 2 3 | tar-xzvfcudnn-7.0-linux-x64-v3.0-prod.tgz sudo cpcuda/include/cudnn.h/usr/local/cuda/include/ sudocpcuda/lib64/libcudnn*/usr/local/cuda/lib64/ |
sudo pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git
1 | sudopip3install--upgrade--no-depsgit+git://github.com/Theano/Theano.git |
Theano’s config file:
[global]
floatX = float32
device = gpu
optimizer = fast_run
[lib]
cnmem = 0.9
[nvcc]
fastmath = True
[blas]
ldflags = -llapack -lblas
1 2 3 4 5 6 7 8 9 10 11 12 13 | [global] floatX =float32 device=gpu optimizer =fast_run [lib] cnmem=0.9 [nvcc] fastmath =True [blas] ldflags=-llapack-lblas |
Install Keras (a neat library by Francois Chollet that is written in the spirit of Torch but is written in Python/Theano. Documentation can be found atkeras.io.
git clone https://github.com/fchollet/keras.git keras
cd keras
sudo python3 setup.py install
1 2 3 | gitclonehttps://github.com/fchollet/keras.gitkeras cd keras sudopython3setup.pyinstall |
cd keras/examples/
python3 mnist_cnn.py
1 2 | cdkeras/examples/ python3 mnist_cnn.py |
Using gpu device X: GeForce GTX 980M (CNMeM is enabled)
1 | UsinggpudeviceX:GeForceGTX980M(CNMeMisenabled) |
THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python3 mnist_cnn.py
1 | THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32python3mnist_cnn.py |
cluster that has an NVIDIA K520 GRID CPU. There are likely to be additional optimizations that can be performed, but this should give you a fairly optimized installation.
Happy Deep Learning!!!
-------------------------------------------------------
.theano需要赋权限,不然cuda installed but no gpu device
acpi pcc probe问题
可以进入recovery mode
nomedeset 部分需要修改,具体可以根据问题收集资料解决。
------------------------------------------------------
Link: http://robotics.usc.edu/~ampereir/wordpress/?p=1247
相关文章推荐
- Ubuntu 默认壁纸历代记
- Ubuntu Remix Cinnamon 20.04 评测:Ubuntu 与 Cinnamon 的完美融合
- 关于Ubuntu 11.10启动提示waiting for the network configuration的问题
- 在 Ubuntu 桌面中使用文件和文件夹
- ubuntu下chrome无法同步问题解决
- Ubuntu Linux使用体验
- 使用 GNOME 优化工具自定义 Linux 桌面的 10 种方法
- 以Ubuntu 9.04为例 将工作环境迁移到 Linux
- VirtualBox虚拟机XP与宿主机Ubuntu互访共享文件夹
- 从USB安装Ubuntu Server 10.04.3 图文详解
- Ubuntu 15.04 正式版发布下载
- Linux-Ubuntu 10.04安装Cadence-ic610 方法总结图解
- Ubuntu 12.04和Windows 7双系统安装图解
- 开机出现:grub rescue的修复方法
- Ubuntu连接Android真机调试
- 你应该选择 Ubuntu 还是 Fedora?
- 100 个最佳 Ubuntu 应用(中)
- 看看我的Ubuntu Linux截图
- Ubuntu 12.04 LTS服务器版安装过程及使用图解
- Windows 7/8/8.1 硬盘安装 Ubuntu 14.04 实现双系统