第一次在tensorflow中运行mnist,相关程序,请注意分清楚是tensorflow,安装的时候cpu,还是GPU,当然直接运行都会报错,当用GPU时候,报错后加入下面语句,可以运行

failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED

<div class="article-info-box">
    <div class="article-bar-top d-flex">
                                            <span class="time">2018年05月31日 09:55:10</span>
        <div class="float-right">
            <span class="read-count">阅读数:104</span>
                                        </div>
    </div>
</div>
<article>
    <div id="article_content" class="article_content clearfix csdn-tracking-statistics" data-pid="blog" data-mod="popu_307" data-dsm="post">
                <div class="markdown_views">
            <p>问题:</p>
2018-05-31 09:42:41.796259: E tensorflow/stream_executor/cuda/cuda_blas.cc:366] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2018-05-31 09:42:41.796310: W tensorflow/stream_executor/stream.cc:1756] attempting to perform BLAS operation using StreamExecutor without BLAS support
2018-05-31 09:42:41.797860: E tensorflow/stream_executor/cuda/cuda_blas.cc:366] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2018-05-31 09:42:41.797887: W tensorflow/stream_executor/stream.cc:1756] attempting to perform BLAS operation using StreamExecutor without BLAS support
2018-05-31 09:42:41.798648: E tensorflow/stream_executor/cuda/cuda_blas.cc:366] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2018-05-31 09:42:41.798673: W tensorflow/stream_executor/stream.cc:1756] attempting to perform BLAS operation using StreamExecutor without BLAS support
Exception in thread Thread-2:

  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

实验环境:

   Ubuntu16.04LTS
   tensorflow1.3版本
   pycharm2017.2
   python2.7
  
  
  • 1
  • 2
  • 3
  • 4

原因: 在创建session时没有使用想让它用的GPU


解决方法:设置 CUDA_VISIBLE_DEVICES
(1)在python中添加语句

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
#....这样就OK了
  
  
  • 1
  • 2
  • 3

(2)运行界面添加cuda

   CUDA_VISIBLE_DEVICES=1 python experiment*****.py
  
  
  • 1

(3)export的方法我没有尝试,应该也可以

参考
[1].https://stackoverflow.com/questions/37893755/tensorflow-set-cuda-visible-devices-within-jupyter
[2].https://stackoverflow.com/questions/44375177/tensorflow-unusual-cuda-related-error



        </article>

    <div class="article-bar-bottom">
            <div class="article-copyright">
        版权声明:本文为博主原创文章,未经博主允许不得转载。          https://blog.csdn.net/gsww404/article/details/80519725      </div>
                    <div class="tags-box artic-tag-box">
        <span class="label">文章标签:</span>
                    <a class="tag-link" href="http://so.csdn.net/so/search/s.do?q=failed to create cublas handle&amp;t=blog" target="_blank">failed to create cublas handle                     </a><a class="tag-link" href="http://so.csdn.net/so/search/s.do?q=&nbsp;attempting to perform BLAS op&amp;t=blog" target="_blank">&nbsp;attempting to perform BLAS op                       </a>
    </div>
                    <div class="tags-box">
        <span class="label">个人分类:</span>
                    <a class="tag-link" href="https://blog.csdn.net/gsww404/article/category/7192906" target="_blank">Tensorflow                        </a>
    </div>
                            <div class="tags-box hot-word">
        <span class="label">相关热词:</span>
                    <a class="tag-link" href="https://blog.csdn.net/menghuanbeike/article/details/74586947" target="_blank">
        请求failed            </a>
                    <a class="tag-link" href="https://blog.csdn.net/qq_36281716/article/details/52711285" target="_blank">
        failed函数            </a>
                    <a class="tag-link" href="https://blog.csdn.net/lostspeed/article/details/12769827" target="_blank">
        failed宏         </a>
                </div>
        </div>

<!-- !empty($pre_next_article[0]) -->
        <div class="related-article related-article-prev text-truncate">
    <a href="https://blog.csdn.net/gsww404/article/details/80507704">
        <span>上一篇</span>TensorFlow: InternalError: Blas SGEMM launch failed     </a>
</div>
            <div class="related-article related-article-next text-truncate">
    <a href="https://blog.csdn.net/gsww404/article/details/80533073">
        <span>下一篇</span>深入探讨 神经网络参数、超参数调节       </a>
</div>
</div>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值