代码之家  ›  专栏  ›  技术社区  ›  I. A Ziang Yan

如何在Windows10上安装CUDA分析工具界面

  •  -1
  • I. A Ziang Yan  · 技术社区  · 6 年前

    我的目标是找出在TensorFlow中构建的神经网络模型的内存使用情况。因此,我发现必须在我的Windows10机器上安装以下库:CUDA分析工具接口。因此,这可以通过以下途径实现: sudo apt-get install libcupti-dev 在Linux上。这个命令在Windows10上的等效性是什么?请注意,我的机器上有CUDA V9.0和TensorFlow 1.8。

    我尝试了以下代码:

    import os
    import tempfile
    
    import tensorflow as tf
    from tensorflow.contrib.layers import fully_connected as fc
    from tensorflow.examples.tutorials.mnist import input_data
    from tensorflow.python.client import timeline
    
    batch_size = 100
    
    inputs = tf.placeholder(tf.float32, [batch_size, 784])
    targets = tf.placeholder(tf.float32, [batch_size, 10])
    
    with tf.variable_scope("layer_1"):
        fc_1_out = fc(inputs, num_outputs=500, activation_fn=tf.nn.sigmoid)
    with tf.variable_scope("layer_2"):
        fc_2_out = fc(fc_1_out, num_outputs=784, activation_fn=tf.nn.sigmoid)
    with tf.variable_scope("layer_3"):
        logits = fc(fc_2_out, num_outputs=10)
    
    loss = tf.reduce_mean(
        tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=targets))
    train_op = tf.train.GradientDescentOptimizer(0.01).minimize(loss)
    
    if __name__ == '__main__':
        mnist_save_dir = os.path.join(tempfile.gettempdir(), 'MNIST_data')
        mnist = input_data.read_data_sets(mnist_save_dir, one_hot=True)
    
        config = tf.ConfigProto()
        config.gpu_options.allow_growth = True
        with tf.Session(config=config) as sess:
            sess.run(tf.global_variables_initializer())
    
            options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
            run_metadata = tf.RunMetadata()
            for i in range(3):
                batch_input, batch_target = mnist.train.next_batch(batch_size)
                feed_dict = {inputs: batch_input,
                             targets: batch_target}
    
                sess.run(train_op,
                         feed_dict=feed_dict,
                         options=options,
                         run_metadata=run_metadata)
    
                fetched_timeline = timeline.Timeline(run_metadata.step_stats)
                chrome_trace = fetched_timeline.generate_chrome_trace_format()
                with open('timeline_02_step_%d.json' % i, 'w') as f:
                    f.write(chrome_trace)
    

    我得到了以下错误:

    2019-01-03 13:49:50.347482: I T:\src\github\tensorflow\tensorflow\stream_executor\dso_loader.cc:142] Couldn't open CUDA library cupti64_90.dll
    2019-01-03 13:49:50.347629: F T:\src\github\tensorflow\tensorflow/stream_executor/lib/statusor.h:212] Non-OK-status: status_ status: Failed precondition: could not dlopen DSO: cupti64_90.dll; dlerror: cupti64_90.dll not found
    
    Process finished with exit code -1073740791 (0xC0000409)
    

    非常感谢您的帮助!!

    1 回复  |  直到 6 年前
        1
  •  0
  •   I. A Ziang Yan    6 年前

    问题解决依据 https://github.com/tensorflow/tensorflow/issues/6235 @梦岗标记为:

    “文件cupti64_90.dll位于c:\program files\nvidia gpu computing toolkit\cuda\v9.0\extras\cupti\libx64中。我刚刚解决了这个问题,将DLL复制到C:\Program Files\Nvidia GPU Computing Toolkit\CUDA\V8.0\bin中,将同一位置的文件cupti.lib复制到C:\Program Files\Nvidia GPU Computing Toolkit\CUDA\V9.0\lib\x64中。这很管用!”