ubuntu16.04安装cuda8.0和tensorflow1.3

来源:互联网 发布:生化危机人工智能白后 编辑:程序博客网 时间:2024/06/05 11:03

好久没有写博客了,最近工作忙,写个配置环境的博客。本人的电脑是1080ti

  • 1 安装ubuntu16.04。网上很多教程,也很简单,之所以选择16.04是因为这个是长期支持版本。建议安装过程中使用英文版,这样便可以在后续使用过程中避免中文路径的影响。这个过程需要一些时间。
  • 2 安装ubuntu结束后,重启电脑后很有可能进不去,出现pcie的错误。对于这个错误我也挣扎了很久,最后发现是由于16.04版本中不支持nvidia的驱动,想要解决该问题有两种途径:1.使用14.04安装然后升级16.04,14.04可以支持nvidia的驱动,但是该方法我没有试过,按理说是可以的; 2. 使用集成显卡开机,有的主办可以设置为只用集成显卡启动,但是对于华硕主办就不行了,那么可以拔掉显卡,使用apt-get install nvidia- 安装驱动,然后关机,插上显卡。该这整个过程中,需要注意显示器到底是插到那里去了。一旦进入了系统后,一定要立刻在system setting里设置附加驱动为nvidia。
  • 3 安装cuda8.0。这个过程中也很多教程也很简单了,注意在bashrc中添加环境变量就好了。同时注意检查cuda8.0 是否安装成功了,
    一个看nvcc -V是否出现信息
    另一个要看
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuerysudo make./deviceQuery
  • 4 安装cudnn。如果安装tensorflow1.3及以上的版本的花,安装cudnn6.0。如果安装tensorflow1.2,安装cudnn5.0版本。同样该过程只是拷贝过去cudnn的头文件而已。
  • 5 安装anaconda。官网下载很慢,可以去清华大学的镜像下载anaconda并对conda增加源。安装过程也简单,记得添加到bashrc文件中。安装完成后,在终端中python一下,检查下是不是调用的anaconda。至于选择python2还是python3根据个人兴趣了。我觉得没啥差别。
  • 6 安装tensorflow。直接使用pip install tensorflow-gpu==1.3。安装结束后,可以实验下是否成功。在终端中输入python。然后输入
    `
    import tensorflow as tf
    b=tf.Session()

    出现如下的东西。那么就是安装成功了。之所以出现wasn’t这类的东西是说,如果从源码编译的话我的性能会更好而已。但是有些麻烦。

yjl@yjl:~$ python
Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
- >>> import tensorflow as tf
- >>> tf.Session()

2017-11-26 02:12:17.357750: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-26 02:12:17.357804: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-26 02:12:17.357821: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-11-26 02:12:17.357836: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-26 02:12:17.357856: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-11-26 02:12:17.453670: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-26 02:12:17.453862: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.6575
pciBusID 0000:01:00.0
Total memory: 10.91GiB
Free memory: 391.31MiB
2017-11-26 02:12:17.453874: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0
2017-11-26 02:12:17.453878: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0: Y
2017-11-26 02:12:17.453882: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0)

阅读全文
0 0
原创粉丝点击