TensorFlow 报错 failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
2017-06-16 14:39
2046 查看
今天使用python virtualenv安装TensorFlow gpu版,一直报错各种配置版本按官网来的https://www.tensorflow.org/cuda8.0 cudnn5.1错误如下2017-06-16 13:53:53.632070: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x3f287f0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.2017-06-16 13:53:53.632367: E tensorflow/core/common_runtime/direct_session.cc:138] Internal: failed initializing StreamExecutor for CUDA device ordinal 1: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICETraceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1292, in __init__ super(Session, self).__init__(target, graph, config=config) File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 562, in __init__ self._session = tf_session.TF_NewDeprecatedSession(opts, status) File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__ next(self.gen) File "/home/zw/jy/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status))tensorflow.python.framework.errors_impl.InternalError: Failed to create session.后来参考一下连接解决错误 https://stackoverflow.com/questions/37893755/tensorflow-set-cuda-visible-devices-within-jupyter https://stackoverflow.com/questions/44375177/tensorflow-unusual-cuda-related-error http://www.cnblogs.com/darkknightzh/p/6591923.html 原因是在创建session时没有使用我想让它用的gpu所以需要设置
CUDA_VISIBLE_DEVICES方法1 在python程序中
import os os.environ["CUDA_VISIBLE_DEVICES"] = "1"
方法2
运行时
CUDA_VISIBLE_DEVICES=1 python **.py
方法3
直接在环境变量中 export
相关文章推荐
- TensorFlow学习笔记 速记2 报错:failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
- tensorflow安装问题:No module named pywrap_tensorflow_internal&failed call to cuInit:CUDA_ERROR_NO_DEVICE
- Tensorflow: failed call to cuInit: CUDA_ERROR_UNKNOWN
- TensorFlow in nvidia-docker: failed call to cuInit: CUDA_ERROR_UNKNOWN
- Check failed: error == cudaSuccess (8 vs. 0) invalid device function
- Cuda kernel failed. Error: invalid device function
- Cuda kernel failed. Error: invalid device function
- 【CUDA开发】 Check failed: error == cudaSuccess (8 vs. 0) invalid device function
- caffe运行错误: im2col.cu:61] Check failed: error == cudaSuccess (8 vs. 0) invalid device function
- Check failed: error == cudaSuccess (8 vs. 0) invalid device function
- pcl运行:Error: "invalid device function" complaining about cuda/tsdf_volume.cu:170
- Fatal error: Failed to identify device. Check connections and/or reset hardware
- Android真机调试超时错误解决方法(Android error: Failed to install *.apk on device *: timeout )
- FAILED: Error in metadata: MetaException(message:Got exception: java.net.ConnectException Call to ha
- the module '*' was loaded but the call to DllRegisterServer failed with error 0x80004005
- transfer error: Invalid argument. Failed to push selection: Invalid argument
- “Failed to upload *.app on Device ” Error in iPhone
- Error:Call to localhost/127.0.0.1:9000 failed on connetion exception: java .net.ConnectionException:
- ERROR: InitEthDevice: Failed to initialize Ethernet controller. ERROR: OEMPlatformInit: Failed to i
- Fatal error: Failed to identify device. Check connections and/or reset hardware