zoukankan      html  css  js  c++  java
  • Tensorflow之安装GPU版错误集合

        在根据教程http://blog.csdn.net/sb19931201/article/details/53648615安装好全部的时候,却无情的给我抛了几个错:
    1、AttributeError: module 'tensorflow' has no attribute 'device'
        这貌似是我先pip了tensorflow-gpu的包,再添加cuDnn库。
    2、ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit
        在下载的CUDA的时候,随手下了9.0的,结果只支持8.0.。
    3、ImportError: Could not find 'cudnn64_6.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 6 from this URL: https://developer.nvidia.com/cudnn
        明明看教程的时候写的是5.1版本,我也下的5.1啊,这是为什么?原来是因为我的tensorflow-gpu的版本高于1.3,所以用6.0。
    4、InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'add': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
    [[Node: add = Add[T=DT_FLOAT, _device="/device:GPU:0"](a, b)]]
        还给我弹了下面这个框

    这个问题根据下面改就行。
    桌面上空白地方右键,进入NVIDIA面板,然后下图

    选择第二个,点击应用,再重启电脑即可,记得重启电脑。
    我用的以下代码测试:

    import tensorflow as tf
    
    # # 通过tf.device将运算指定到特定的设备上。
    with tf.device('/cpu:0'):
        a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')
        b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b')
    with tf.device('/gpu:0'):
         c=a+b
    # 通过log_device_placement参数来记录运行每一个运算的设备。
    sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
    print(sess.run(c))
    文章来源:NSGUF,欢迎分享,转载请保留出处
  • 相关阅读:
    【[国家集训队]最长双回文串】
    【[国家集训队]Crash的数字表格 / JZPTAB】
    【YY的GCD】
    【于神之怒加强版】
    【[SDOI2015]约数个数和】
    【[TJOI2010]电影迷】
    【[SDOI2011]拦截导弹】
    【[SDOI2014]数表】
    linux系统编程之管道(三)
    linux系统编程之管道(二)
  • 原文地址:https://www.cnblogs.com/NSGUF/p/7995482.html
Copyright © 2011-2022 走看看