0. 安装说明
由于之前安装caffe 的时候使用的cuda7.0,并不想破坏它,同时又不想使用过低版本的tensorflow,所以才用了Virtualenv installation 方式安装。
1. 本机配置:
系统:Ubuntu14.04
显卡:GTX1080
CPU:i7 6500K,其他不重要了
2. 安装的版本:
tensorflow r0.10
cuda 7.5
cudnn v5.1(我安装的5.0会出现问题)
3. 参考网址
官网(r0.10,使用Virtualenv installation 安装):
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#requirements
cuda: (需要选对版本)
https://developer.nvidia.com/cuda-downloads
cudnn:(需要注册)
https://developer.nvidia.com/rdp/cudnn-download
4. 安装参考网址
http://www.pyimagesearch.com/2016/07/04/how-to-install-cuda-toolkit-and-cudnn-for-deep-learning/
5. 安装流程
5.1 安装1080显卡驱动
1: Download the Nvidia driver in right version (NVIDIA GeForce GTX1080)
2: Edit the blacklist.conf:
sudo gedit /etc/modprobe.d/blacklist.conf
add :
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
__block_line__
3: sudo apt-get remove –purge nvidia-*
**sudo apt-get remove –purge xserver-xorg-video-nouveau**
4: reboot and into computer using ‘Ctrl+ALT+F1’ using the ‘Ctrl+ALT+F7’ return xservers
5: sudo /etc/init.d/gdm stop or sudo /etc/init.d/lightdm stop
6: in the driver file,which downloaded in step 1
sudo sh NVIDIA.run
7: sudo /etc/init.d/gdm restart or sudo /etc/init.d/lightdm restart
8: sudo reboot
5.2 安装cuda
1: Download the cuda 7.5 from the cuda_driver
IMPORTANCE:download .runfile
2: reboot and ctrl+alt+F1
sudo /etc/init.d/lightdm stop
3: sudo sh cuda.run
IMPORTANCE:ALL SHOULD INSTALL EXCEPT:DRIVER(because we have installed the nvidia driver and the cuda.runfile don’t include the nvidia driver)
4: sudo /etc/init.d/lightdm restart
5: reboot
5.3 安装cudnn
tar -zxf cudnn-7.5-linux-x64-v5.1-ga.tgz
cd cuda
sudo cp lib64/* /usr/local/cuda/lib64/
sudo cp include/* /usr/local/cuda/include/
5.4 添加环境变量
gedit .bashrc
export CUDA_HOME=/usr/local/cuda
export PATH="/usr/local/cuda/bin:/usr/local/lib/:${JAVA_HOME}/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:${LD_LIBRARY_PATH}"
source .bashrc
5.5 Install tensorflow
sudo apt-get install python-pip python-dev python-virtualenv
virtualenv --system-site-packages ~/tensorflow
source ~/tensorflow/bin/activate
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
(tensorflow)$ pip install --upgrade $TF_BINARY_URL
6 Important Issue
1 https://github.com/tensorflow/tensorflow/issues/4251
2 如果测试的时候无法导入cudnn,注意LD_LIBRARY_PATH 路径下是否存在可用的cudnn
3 测试通过需要看看 python -m tensorflow.models.image.mnist.convolutional,不能仅仅看import tensorflow as tf 同时不能用任何问题才能认为安装成功
4 更新一个刚刚解决的问题,在安装tensorflow上经常会出现numpy 版本冲突问题
参考:http://stackoverflow.com/questions/16391335/using-old-version-of-numpy-even-with-a-newer-version-installed
先要找到numpy的存在位置
ipython
import numpy
print numpy.__version__
print numpy.__file__
在我自己的配置下,因为是Virtualenv installation 方式安装,所以numpy 会在两个地方:
/usr/local/lib/python2.7/dist-packages/numpy/__init__.pyc
/home/dex_hand/tensorflow/lib/python2.7/site-packages/numpy/__init__.pyc
所以我通过这样的方式把两个地方的numpy 文件夹 都删除,
rm -rf numpy
最后通过pip install numpy 重新安装回来,这个时候在tensorflow这个虚拟环境下也能使用到这个版本(1.11.0)的版本的numpy了