python-Tensorflow无法分配设备进行 *** 作

python-Tensorflow无法分配设备进行 *** 作,第1张

概述我正在尝试在计算机上运行NVidia's face generating demo.我正在使用Windows10.我已经下载了源代码,并试图按照页面下方的步骤进行 *** 作.我已经为我的GTX1060安装了最新的NVidia驱动程序,该驱动程序应该是支持cuda功能的设备.我已经安装了Cuda Toolkit和TensorFlow所需的cuDNN SDK.但是,运

我正在尝试在计算机上运行NVidia’s face generating demo.我正在使用windows10.我已经下载了源代码,并试图按照页面下方的步骤进行 *** 作.我已经为我的GTX1060安装了最新的NVIDia驱动程序,该驱动程序应该是支持cuda功能的设备.我已经安装了Cuda Toolkit和TensorFlow所需的cuDNN SDK.

但是,运行import_example.py脚本时,出现以下错误.谁能告诉我我在做什么错?

   2019-03-19 20:16:26.112574: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your cpu supports instructions that this TensorFlow binary was not compiled to use: AVX2    WARNING:tensorflow:From C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.    Instructions for updating:    Colocations handled automatically by placer.    Traceback (most recent call last):      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 1334,in _do_call        return fn(*args)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 1319,in _run_fn        options,Feed_dict,fetch_List,target_List,run_Metadata)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 1407,in _call_tf_sessionrun        run_Metadata)    tensorflow.python.framework.errors_impl.InvalIDArgumentError: Cannot assign a device for operation G_paper_1/Run/G_paper_1/latents_in: {{node G_paper_1/Run/G_paper_1/latents_in}}was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:cpu:0 ]. Make sure the device specification refers to a valID device. The requested device appears to be a GPU,but CUDA is not enabled.             [[{{node G_paper_1/Run/G_paper_1/latents_in}}]]    During handling of the above exception,another exception occurred:    Traceback (most recent call last):      file ".\import_example.py",line 21,in <module>        images = Gs.run(latents,labels)      file "C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py",line 668,in run        mb_out = tf.get_default_session().run(out_expr,dict(zip(self.input_templates,mb_in)))      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 929,in run        run_Metadata_ptr)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 1152,in _run        Feed_dict_tensor,options,line 1328,in _do_run        run_Metadata)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\clIEnt\session.py",line 1348,in _do_call        raise type(e)(node_def,op,message)    tensorflow.python.framework.errors_impl.InvalIDArgumentError: Cannot assign a device for operation G_paper_1/Run/G_paper_1/latents_in: node G_paper_1/Run/G_paper_1/latents_in (defined at C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py:508) was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:cpu:0 ]. Make sure the device specification refers to a valID device. The requested device appears to be a GPU,but CUDA is not enabled.             [[node G_paper_1/Run/G_paper_1/latents_in (defined at C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py:508) ]]    Caused by op 'G_paper_1/Run/G_paper_1/latents_in',defined at:      file ".\import_example.py",line 645,in run        out_expr = self.get_output_for(*in_split[gpu],return_as_List=True,**dynamic_kwargs)      file "C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py",line 508,in get_output_for        named_inputs = [tf.IDentity(expr,name=name) for expr,name in zip(in_expr,self.input_names)]      file "C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py",in <Listcomp>        named_inputs = [tf.IDentity(expr,self.input_names)]      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\util\dispatch.py",line 180,in wrapper        return target(*args,**kwargs)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\ops\array_ops.py",line 81,in IDentity        ret = gen_array_ops.IDentity(input,name=name)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\ops\gen_array_ops.py",line 4537,in IDentity        "IDentity",input=input,name=name)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\framework\op_def_library.py",line 788,in _apply_op_helper        op_def=op_def)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\util\deprecation.py",line 507,in new_func        return func(*args,**kwargs)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\framework\ops.py",line 3300,in create_op        op_def=op_def)      file "C:\Users\me\AppData\Local\Programs\Python\python37\lib\site-packages\tensorflow\python\framework\ops.py",line 1801,in __init__        self._traceback = tf_stack.extract_stack()    InvalIDArgumentError (see above for traceback): Cannot assign a device for operation G_paper_1/Run/G_paper_1/latents_in: node G_paper_1/Run/G_paper_1/latents_in (defined at C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py:508) was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:cpu:0 ]. Make sure the device specification refers to a valID device. The requested device appears to be a GPU,but CUDA is not enabled.             [[node G_paper_1/Run/G_paper_1/latents_in (defined at C:\Users\me\Desktop\progressive_growing_of_gans-master\tfutil.py:508) ]]
最佳答案

Cannot assign a device for operation
G_paper_1/Run/G_paper_1/latents_in: {{node
G_paper_1/Run/G_paper_1/latents_in}}was explicitly assigned to
/device:GPU:0 but available devices are [
/job:localhost/replica:0/task:0/device:cpu:0 ]

您是否安装了tensorflow或tensorflow-gpu?如果要使用GPU,则后者是您想要的.

这也可能是版本兼容性问题.
首先,检查是否安装了nvIDia驱动程序:nvIDia-smi,您应该得到类似以下的内容:

Mon Apr 1 12:30:02 2019       +------------------------------------------------------+                       | NVIDIA-SMI 3.295.41   Driver Version: 295.41         |                       |-------------------------------+----------------------+----------------------+| Nb.  name                     | Bus ID        disp.  | Volatile ECC SB / DB || Fan   Temp   Power Usage /Cap | Memory Usage         | GPU Util. Compute M. ||===============================+======================+======================|| 0.  GeForce GTX 580           | 0000:25:00.0  N/A    |       N/A        N/A ||  54%   70 C  N/A   N/A /  N/A |  25%  383MB / 1535MB |  N/A      Default    ||-------------------------------+----------------------+----------------------|| Compute processes:                                               GPU Memory ||  GPU  PID     Process name                                       Usage      ||=============================================================================||  0.           Not Supported                                                 |+-----------------------------------------------------------------------------+

之后,使用nvcc –version检查您拥有的cuda版本.例:

nvcc: NVIDIA (R) Cuda compiler drivercopyright (c) 2005-2016 NVIDIA CorporationBuilt on Mon_Apr__1_12:34:01_CDT_2016Cuda compilation tools,release 8.0,V8.0.44

最终,检查是否已安装兼容版本的python / tensorflow / cuda.为此,对于大多数人来说,使用table作为参考似乎可行.

安装驱动程序后,不要忘记重启!

总结

以上是内存溢出为你收集整理的python-Tensorflow无法分配设备进行 *** 作 全部内容,希望文章能够帮你解决python-Tensorflow无法分配设备进行 *** 作 所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1199617.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存