failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED

问题:

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:

实验环境:

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

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


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

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

(2)运行界面添加cuda

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

(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

你可能感兴趣的:(Tensorflow)