win10+tensorflow-gpu环境配置遇到的问题与解决方案

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_35908189/article/details/90215304

win10+anaconda+CUDA+cuDDN+tensorflow+GPU环境配置遇到的问题与解决方案

购置新电脑之后,在windows10情况下搭建tensorflow环境,遇到很多问题,因此在这里对相应的解决方法进行一个记录2019.5.12

本机配置

1.win10-64家庭版
2.NVIDIA GeForce GTX 1060
3. Intel® Core ™ i7-875
0
软件配置
1.anaconda3 5.1.0
2.CUDA9.0
3.cUDDN 7.5.0
4.python3.5
5.tensorflow1.12.1(GPU版本)
6.VS2015( 重要

下载与安装

下载参考以下文章:
[Win10 64 位Tensorflow-gpu安装(VS2017+CUDA9.2+cuDNN7.1.4+python3.6.5)https://blog.csdn.net/wwtor/article/details/80603296
其中遇到问题以及解决方案有如下几点:
重要!在安装之前一定要下载正确相匹配版本的CUDD、cuDNN、tensorflow,否则常常会安装失败,从头再来一遍!!!

1.安装CUDA失败
解决方案
首先确保VS环境,之前安装VS2019环境,结果不可以安装CUDA因此换为2015版本。再而可以尝试删除电脑自带的显卡驱动然后再安装CUDA,在这过程中发现一个小程序可以在安全模式下删除去所有显卡驱动。
DUU显卡驱动删除
当然在安装之前必须了解自己的显卡支持的CUDA版本,本机安装选择9.0因此cuDNN选择7.5系列,解压之后将相应的文件替换就可以。

2.anaconda安装包下载速度太慢
之前加载清华镜像,但是截止到现在已经不能用,可以使用中科大的镜像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
下载速度可以达到几兆每秒
3.tensorflow搭建失败
首先在tensorflow-GPU环境必须确保python是3.5或者是3.6,
create -n tensorflow=python3.5
在anaconda promp界面下载tensorflow-gpu,在这个过程一直显示失败,原来是在安装的时候没有在意,安装了cpu版本的tensorflow,然后又安装了GPU版本的,需要将所有的tensorflow全部卸载,然后重新安装GPU版本。
此时tensorflow版本很重要,在使用1.7、1.5、1.3失败之后,尝试了几次之后发现1.12.1版本的可以使用。

参考文章:
使用anaconda安装tensorflow (windows10环境)

展开阅读全文

tensorflow-gpu 问题

02-28

当我运行https://blog.csdn.net/u013044310/article/details/79556099上的train_tripletloss.py时,出现错误,环境是GTX1060,win10,tensorflow1.12.0-gpu,cuda10,cudnn7.4,已经测试可以在GPU上运行。请问错误是什么原因?rn错误信息如下:rn****************************************************************************************************rn2019-02-28 11:09:58.444671: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at conv_ops.cc:746 : Resource exhausted: OOM when allocating tensor with shape[90,896,8,8] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfcrnTraceback (most recent call last):rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_callrn return fn(*args)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fnrn options, feed_dict, fetch_list, target_list, run_metadata)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrunrn run_metadata)rntensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[90,896,8,8] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfcrn [[node InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/Conv2D = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](InceptionResnetV1/Repeat_1/block17_8/concat, InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/weights/read)]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rn [[node Adagrad/update/_1354 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_22871_Adagrad/update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rnrnDuring handling of the above exception, another exception occurred:rnrnTraceback (most recent call last):rn File "D:/PycharmProject/facereg/understand_facenet/train_tripletloss.py", line 514, in rn main(parse_arguments(sys.argv[1:]))rn File "D:/PycharmProject/facereg/understand_facenet/train_tripletloss.py", line 185, in mainrn args.embedding_size, anchor, positive, negative, triplet_loss)rn File "D:/PycharmProject/facereg/understand_facenet/train_tripletloss.py", line 263, in trainrn err, _, step, emb, lab = sess.run([loss, train_op, global_step, embeddings, labels_batch], feed_dict=feed_dict)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 929, in runrn run_metadata_ptr)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _runrn feed_dict_tensor, options, run_metadata)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_runrn run_metadata)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_callrn raise type(e)(node_def, op, message)rntensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[90,896,8,8] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfcrn [[node InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/Conv2D (defined at D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py:1057) = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](InceptionResnetV1/Repeat_1/block17_8/concat, InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/weights/read)]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rnrn [[node Adagrad/update/_1354 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_22871_Adagrad/update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rnrnCaused by op 'InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/Conv2D', defined at:rn File "D:/PycharmProject/facereg/understand_facenet/train_tripletloss.py", line 514, in rn main(parse_arguments(sys.argv[1:]))rn File "D:/PycharmProject/facereg/understand_facenet/train_tripletloss.py", line 122, in mainrn weight_decay=args.weight_decay)rn File "D:\PycharmProject\facereg\understand_facenet\models\inception_resnet_v1.py", line 140, in inferencern dropout_keep_prob=keep_probability, bottleneck_layer_size=bottleneck_layer_size, reuse=reuse)rn File "D:\PycharmProject\facereg\understand_facenet\models\inception_resnet_v1.py", line 207, in inception_resnet_v1rn net = slim.repeat(net, 10, block17, scale=0.10)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 2612, in repeatrn outputs = layer(outputs, *args, **kwargs)rn File "D:\PycharmProject\facereg\understand_facenet\models\inception_resnet_v1.py", line 55, in block17rn activation_fn=None, scope='Conv2d_1x1')rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 182, in func_with_argsrn return func(*args, **current_args)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1154, in convolution2drn conv_dims=2)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 182, in func_with_argsrn return func(*args, **current_args)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1057, in convolutionrn outputs = layer.apply(inputs)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 817, in applyrn return self.__call__(inputs, *args, **kwargs)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\layers\base.py", line 374, in __call__rn outputs = super(Layer, self).__call__(inputs, *args, **kwargs)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 757, in __call__rn outputs = self.call(inputs, *args, **kwargs)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\keras\layers\convolutional.py", line 194, in callrn outputs = self._convolution_op(inputs, self.kernel)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 868, in __call__rn return self.conv_op(inp, filter)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 520, in __call__rn return self.call(inp, filter)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 204, in __call__rn name=self.name)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 957, in conv2drn data_format=data_format, dilations=dilations, name=name)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helperrn op_def=op_def)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_funcrn return func(*args, **kwargs)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\framework\ops.py", line 3274, in create_oprn op_def=op_def)rn File "D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\python\framework\ops.py", line 1770, in __init__rn self._traceback = tf_stack.extract_stack()rnrnResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[90,896,8,8] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfcrn [[node InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/Conv2D (defined at D:\Software\Anaconda\envs\py36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py:1057) = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](InceptionResnetV1/Repeat_1/block17_8/concat, InceptionResnetV1/Repeat_1/block17_8/Conv2d_1x1/weights/read)]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rnrn [[node Adagrad/update/_1354 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_22871_Adagrad/update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]rnHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.rn 论坛

没有更多推荐了,返回首页