PermissionError: [Errno 13] Permission denied等红字问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/slz0813/article/details/78925353

博主先前cpu版本安装正常,gpu版本安装出现红字,未重视。实际测试正常,就囫囵吞枣的使用了。前段时间,突然查看器件,突然发现打印出来的cpu器件,非GPU器件,故而查错。

查看方法例程如下:

# # Creates a graph.  
# a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')  
# b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')  
# c = tf.matmul(a, b)  
# # Creates a session with log_device_placement set to True.  
# sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))  
# # Runs the op.  
# print (sess.run(c))
会显示当前变量和操作所用设备,这里显示为cpu:0设备。


如果成功安装gpu版本,且gpu工作正常情况下,应显示应用设备为gpu,如:



切换运算器件的例程如下:

# Creates a graph.  
with tf.device('/cpu:0'):  
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')  
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')  
    c = tf.matmul(a, b)  
    # Creates a session with log_device_placement set to True.  
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))  
# Runs the op.  
print (sess.run(c))
不能正常切换器件的同学,如果在jupyter notebook下运行,请务必:


直接使用ctrl+enter由于不会清除记忆器件设置,无法正常切换运算器件。请执行上述操作后观察是否成功切换运算器件。


如果,无法切换,一般情况下为tensorflow-gpu 版本未能正常安装,请执行如下语句(卸载当前tensorflow-gpu,再重新安装)(请务必邮件以管理身份运行):

pip uninstall tensorflow-gpu
pip install tensorflow-gpu

安装过程中出现

PermissionError: [Errno 13] Permission denied等红字问题

一般为文件夹读写权限问题,查看anaconda安装路径(提示出现问题的路径),获取管理员权限,且去除只读选项后,重新执行pip install tensorflow-gpu ,方可成功


注意:成功安装一般不存在红字warning,任何存在问题红字,都需要谨慎对待,不可像博主大意略过。


正常配置后,可运行上面的测试程序,可自由切换运算器件基本无误。


感谢您的阅读,本文为原创,若需转载恳请告知标注出处。





猜你喜欢

转载自blog.csdn.net/slz0813/article/details/78925353