ubuntu18.04 tensorflow-gpu

ubuntu18.04 tensorflow-gpu

自己安装过程中的简单记录。

1 2 参考https://blog.csdn.net/tonydz0523/article/details/83109343
1. 驱动
检查显卡和推荐驱动:ubuntu-drivers devices
https://blog.csdn.net/tonydz0523/article/details/83109343
查看推荐驱动

sudo apt install nvidia-390

安装完成后重新启动
检验是否安装成功:

nvidia-smi 

2. 安装CUDA 9.0

(1)gcc降级
下载安装 gcc4.8

sudo apt-get install gcc-4.8
sudo apt-get install g++-4.8

配置:

cd /usr/bin
sudo mv gcc gcc.bak #备份
sudo ln -s gcc-4.8 gcc #重新链接
sudo mv g++ g++.bak
sudo ln -s g++-4.8 g++

查看版本号,显示版本皆为4.8,则说明成功。

gcc -v && g++ -v 

(2)下载安装包
下载连接:
https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=runfilelocal
下载选项选
linux x
86_64
ubuntu
17.04
runfile(local)

安装

sudo chmod +x cuda_9.0.176_384.81_linux.run
./cuda_9.0.176_384.81_linux.run --override

安装过程中问题:
installing with an unsupported configuration?时选择yes
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?为了稳定最好选择no样例可以不安装。

安装结果
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-9.0
Samples: Installed in /home/zhangxi, but missing recommended libraries

Please make sure that

  • PATH includes /usr/local/cuda-9.0/bin
  • LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run -silent -driver

Logfile is /tmp/cuda_install_3897.log
Signal caught, cleaning up

配置环境

sudo vim ~/.bashrc
sudo gedit ~/.bashrc

在最后添加:

export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
export CUDA_HOME=/usr/local/cuda-9.0

重新加载一下:

source ~/.bashrc

查看cuda是否成功安装及成功结果(如果没有nvcc则安装 sudo apt install nvidia-cuda-toolkit):

nvcc -V

nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

3. 安装CUDNN 7.0
参考https://blog.csdn.net/u014670893/article/details/82467384

解压

tar -zxvf cudnn-9.0-linux-x64-v7.tgz

复制相应文件

sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo cp  cuda/include/cudnn.h /usr/local/cuda-9.0/include/

所有用户可读

sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
libcupti
sudo apt-get install libcupti-dev

配置
在~/.bashrc中加入

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

4. 安装tensorflow—gpu

conda create --name tensorflow python=3.5
install tensorflow-gpu==1.1.0

You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

一直报错 可能是tf-gpu 版本不对

pip install tensorflow-gpu==1.8.0

报错:非法指令(核心已转储)

pip uninstall tensorflow

重新安装

pip install tensorflow-gpu==1.5.0

尝试import tensorflow as tf

成功哈哈哈

注意版本对应问题
https://blog.csdn.net/omodao1/article/details/83241074

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值