A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

【转载】 https://blog.csdn.net/xundh/article/details/79139292

环境:Ubuntu

准备环境apt-get 更换源cd /etc/aptsudo apt-get install vim sudo vim sources.list
  • 1
  • 2
  • 3
  • 4
deb 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 multiverse
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
sudo apt-get updatesudo apt-get upgrade
  • 1
  • 2
修改pip源:mkdir ~/.pipvi ~/.pip/pip.conf
  • 1
  • 2
[global]trusted-host =  pypi.douban.comindex-url = http://pypi.douban.com/simple
  • 1
  • 2
  • 3
sudo apt-get install python-pipsudo apt-get install python-numpy swig python-dev python-wheel
  • 1
  • 2
安装Nvidia驱动

在系统设置->软件更新->附加驱动->选择nvidia最新驱动->应用更改

验证:输入命令:

nvidia-smi
  • 1

显示NVIDIA-SMI结果。

下载并安装cuda8sudo sh cuda_8.0.61_375.26_linux.run
  • 1

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
注意是否安装显卡驱动选n。
安装位置:/usr/local/cuda-8.0
sample:/home/admin1

修改环境配置

sudo vim ~/.bashrc
  • 1

加上

export PATH=/usr/local/cuda-8.0/bin:$PATH  export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH  
  • 1
  • 2
  • 3
source ~/.bashrc
  • 1
对gcc降版,降到5.3以下gcc --versionsudo apt-get install gcc-4.8sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
  • 1
  • 2
  • 3

接下来编译测试cuda的sample

cd /usr/local/cuda/samples/1_Utilities/deviceQuery sudo make./deviceQuery
  • 1
  • 2
  • 3

正常的话会输出显卡型号信息。

下载安装cuDNN

https://developer.nvidia.com/rdp/cudnn-download,下载v6.0,安装:

sudo dpkg -i cuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64​.deb
  • 1
安装 tensorflowsudo apt-get install libcupti-devpip install tensorflow-gpu
  • 1
  • 2

上面已经设置了从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
  • 1
  • 2
  • 3
  • 4
  • 5

否则会提示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))


1 个回复

倒序浏览
奈斯
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马