一. Pip安装:
$ sudo apt-get install python3-pip python3-dev # for python3
- $ sudo apt-get install python-pip python-dev # for python
二.安装英伟达显卡驱动
1查看自身版本
或
- lspci | grep -i vga
- lspci | grep -i nvidia
去官网上查看适合你GPU的驱动
http://www.nvidia.com/Download/index.aspx?lang=en-us
2安装
对ubuntu16 可通过 系统设置-软件和更新-附加驱动 安装
3
执行完上述后,重启reboot
安装完后再运行
nvidia-smi 来看看 如果出现了你的GPU列表,则说明驱动安装成功了。 另外也可以通过,或者输入nvidia-settings 查看
三.安装cuda
https://developer.nvidia.com/cuda-downloads据其所说方式安装
ubuntu的gcc编译器是5.4.0,然而cuda8.0不支持5.0以上的编译器,因此需要降级,把编译器版本降到4.9:
在terminal中执行
- sudo apt-get install gcc-4.9 gcc-5 g++-4.9 g++-5
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
- sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
- sudo update-alternatives --set cc /usr/bin/gcc
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
- sudo update-alternatives --set c++ /usr/bin/g++
配置cuda8.0之后主要加上的一个环境变量声明,
- gedit ~/.bashrc
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
通过命令查看CUDA安装是否成功
- cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
- sudo make
- ./deviceQuery
四.cudnn
https://developer.nvidia.com/cudnn tensorflow1.1 支持cudnnv5.1
- cd ~/Downloads/
- tar zxvf cudnn-8.0-linux-x64-v5.1.tgz #解压文件
- # 错误
- Traceback (most recent call last):
- File "<stdin>",line 1,in <module>
- ImportError: No module named rensorflow
- >>> import tensorflow
- Traceback (most recent call last):
- File "<stdin>",in <module>
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/__init__.py",line 24,in <module>
- from tensorflow.python import *
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py",line 51,in <module>
- from tensorflow.python import pywrap_tensorflow
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py",line 52,in <module>
- raise ImportError(msg)
- ImportError: Traceback (most recent call last):
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py",line 41,in <module>
- from tensorflow.python.pywrap_tensorflow_internal import *
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",line 28,in <module>
- _pywrap_tensorflow_internal = swig_import_helper()
- File "/home/yojiu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",in swig_import_helper
- _mod = imp.load_module('_pywrap_tensorflow_internal',fp,pathname,description)
- ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
- Failed to load the native TensorFlow runtime.
- See https://www.tensorflow.org/install/install_sources#common_installation_problems
- for some common reasons and solutions. Include the entire stack trace
- above this error message when asking for help.
五.安装tensorflow
直接配置URL在线 whl 进行安装:
- $ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0rc2-cp27-none-linux_x86_64.whl
- #或其他网站镜像