【转载】 https://blog.csdn.net/xundh/article/details/79139292
环境:Ubuntu 准备环境apt-get 更换源cd /etc/aptsudo apt-get install vim sudo vim sources.listdeb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiversedeb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiversedeb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiversesudo apt-get updatesudo apt-get upgrade修改pip源:mkdir ~/.pipvi ~/.pip/pip.conf[global]trusted-host = pypi.douban.comindex-url = http://pypi.douban.com/simplesudo apt-get install python-pipsudo apt-get install python-numpy swig python-dev python-wheel安装Nvidia驱动在系统设置->软件更新->附加驱动->选择nvidia最新驱动->应用更改 验证:输入命令: nvidia-smi显示NVIDIA-SMI结果。 下载并安装cuda8sudo sh cuda_8.0.61_375.26_linux.runInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
注意是否安装显卡驱动选n。
安装位置:/usr/local/cuda-8.0
sample:/home/admin1 修改环境配置 sudo vim ~/.bashrc加上 export PATH=/usr/local/cuda-8.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH source ~/.bashrc 对gcc降版,降到5.3以下gcc --versionsudo apt-get install gcc-4.8sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100接下来编译测试cuda的sample cd /usr/local/cuda/samples/1_Utilities/deviceQuery sudo make./deviceQuery正常的话会输出显卡型号信息。 下载安装cuDNNhttps://developer.nvidia.com/rdp/cudnn-download,下载v6.0,安装: sudo dpkg -i cuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64.deb安装 tensorflowsudo apt-get install libcupti-devpip install tensorflow-gpu上面已经设置了从douban获取软件件,另外国内清华镜像地址:https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/ **执行:**sudo ldconfig /usr/local/cuda/lib64或者export CUDA_HOME=/usr/local/cudaexport LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH否则会提示libcublas.so.8.0:cannot open shared object file:No such file or directory 测试import tensorflow as tfhello = tf.constant('Hello, TensorFlow!')sess = tf.Session()print(sess.run(hello))
|