爆详细Ubuntu18.04,CUDA9.0,OpenCV3.1,Tensorflow完全配置指南

本文提供了在Ubuntu18.04上安装CUDA9.0、cuDNN、OpenCV3.1和Tensorflow-GPU的详细步骤,包括依赖项安装、Anaconda配置、GCC降级、CUDA驱动与CUDA安装、cuDNN库的添加以及OpenCV的编译和Tensorflow-GPU的安装验证。

2018.7.12更新

最新基于CUDA9.0,cudnn7,和tensorflow1.8
在ubuntu18.04上面的GCC版本是7.3,还是太高了. 我们这里简化了GCC降级的方法. 把GCC降级到了GCC5.5

学习了理论很久了,要折腾实践的东西,那么自然绕不过一些主流的框架,其实那些框架本身是不难安装的,但是一旦涉及到GPU(用于加速),就开始变得麻烦重重,说麻烦也不麻烦,但是真的在第一次安装框架的时候,每一个人都是新人,各种坑。网上全面详细适合新手的教程很少很少,所以在自己安装好的情况下,写一篇详细齐全的希望新手少走弯路。
用的都是最新的,怕用旧的很快就过时了。新的比起旧的其实还更好装一点。下面开始正式讲一下。

安装一些依赖项。
这里安装的依赖项是为后面的安装做准备的,反正是要安装的(当然后面还有一些要安装),这里一行一行复制到你的命令行执行就行。

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install –no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

要是上面的安装出现了一些问题,随时sudo apt-get update.你知道我在说什么。
说到这里,Ubuntu部分就介绍完了。

二.Anaconda

Anaconda下载
之所以还是下回来Anaconda,还是因为它的方便.你可以方便的安装,也可以方便的卸载. 进官网选择你电脑对应的版本下载下来就是了。 下载下来得到相应的一个.sh文件。直接用bash命令来运行就行.如下图。

这里写图片描述

然后一路根据提示安装就行。 到最后,会有一个提示,问你是不是想要把Anaconda的python作为默认的python,这里建议选择是。如下图

这里写图片描述

也就意味着,之后要是安装什么东西需要python的路径的时候,你需要使用这个新的路径.

CUDA 9.0

步骤一:熟悉显卡信息和下载CUDA9.0安装包

相比起安装那些框架,我想有很多人是在这里牺牲的吧…很多人都是摸索了很久,出现了很多问题。
首先是准备工作:
1.自己的显卡需要什么驱动:
http://www.nvidia.com/Download/index.aspx?lang=en-us 进去自己按照自己的具体配置测试一下。

自编译tensorflow1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.无mkl支持; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 TI 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/N]: No ROCm support will be enabled for TensorFlow. Do you wish to build TensorFlow with CUDA support? [y/N]: y CUDA support will be enabled for TensorFlow. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]://home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: bazel build --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
评论 34
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值