首页 文章

在Tensorflow上运行示例程序时获取“PermissionDeniedError”

提问于
浏览
0

抱歉我缺乏知识,但我试图在Tensorflow上运行示例:

import numpy as np
import tensorflow as tf

feature_columns = [tf.feature_column.numeric_column("x", shape=[1])]

estimator = tf.estimator.LinearRegressor(feature_columns=feature_columns)

x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
y_eval = np.array([-1.01, -4.1, -7, 0.])
input_fn = tf.estimator.inputs.numpy_input_fn(
    {"x": x_train}, y_train, batch_size=4, num_epochs=None, shuffle=True)
train_input_fn = tf.estimator.inputs.numpy_input_fn(
    {"x": x_train}, y_train, batch_size=4, num_epochs=1000, shuffle=False)
eval_input_fn = tf.estimator.inputs.numpy_input_fn(
    {"x": x_eval}, y_eval, batch_size=4, num_epochs=1000, shuffle=False)


estimator.train(input_fn=input_fn, steps=1000)

train_metrics = estimator.evaluate(input_fn=train_input_fn)
eval_metrics = estimator.evaluate(input_fn=eval_input_fn)
print("train metrics: %r"% train_metrics)
print("eval metrics: %r"% eval_metrics)

我收到以下错误消息:PermissionDeniedError:无法删除文件:C:\ Users \ Jeff \ AppData \ Local \ Temp \ tmpgpmjek44 \ graph.pbtxt.tmpe31b9f4677cb426fbaef32dadeaf1a4d;没有权限

我发现错误来自“estimator.train(input_fn = input_fn,steps = 1000)”这一行 . 我试着查看文件夹和文件 . 他们已获得完全控制权 . 这可能是一个愚蠢的问题,但这可能是什么原因和解决方案 . 非常感谢你提前!

更新:

我从根运行它并得到以下内容:

(C:\ Users \ Jeff \ Anaconda3)C:\ Users \ Jeff> python test.py警告:tensorflow:使用临时文件夹作为模型目录:C:\ Users \ Jeff \ AppData \ Local \ Temp \ tmp0yywjv30 2017-11 -10 22:54:59.808636:IC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ core \ platform \ cpu_feature_guard.cc:137]您的CPU支持此TensorFlow的说明二进制文件未编译使用:AVX AVX2 2017-11-10 22:55:00.096842:IC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ gpu \ gpu_device.cc:1030]找到具有属性的设备0:名称:GeForce GTX 1060 major:6 minor:1 memoryClockRate(GHz):1.6705 pciBusID:0000:01:00.0 totalMemory:6.00GiB freeMemory:4.99GiB 2017-11-10 22:55:00.096927:IC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ gpu \ gpu_device.cc:1120]创建TensorFlow设备(/ device: GPU:0) - >(设备:0,名称:GeForce GTX 1060,pci总线ID:0000:01:00.0,计算能力:6.1)2017-11-10 22:55:02.51 2317:EC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ stream_executor \ cuda \ cuda_blas.cc:366]无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2017-11-10 22 :55:02.513461:EC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ stream_executor \ cuda \ cuda_blas.cc:366]无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2017-11 -10 22:55:02.513601:EC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ stream_executor \ cuda \ cuda_blas.cc:366]无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2017-11-10 22:55:02.514975:EC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows -gpu \ PY \ 36 \ tensorflow \ stream_executor \ cuda \ cuda_blas.cc:366]无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2017-11-10 22:55:02.515067:WC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ stream_executor \ stream.cc:1901]试图执行BLAS操作使用StreamExecutor而不支持BLAS支持Traceback(最近一次调用l ast):文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,第1323行,在_do_call中返回fn(* args)文件“C:\ Users \ Jeff \ anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py“,第1302行,在_run_fn状态,run_metadata)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ errors_impl.py“,第473行,在退出c_api.TF_GetCode(self.status.status)中)tensorflow.python.framework.errors_impl.InternalError:Blas GEMV启动失败:m = 1,n = 4 [[Node:linear] / linear_model / x / weighted_sum = MatMul [T = DT_FLOAT,transpose_a = false,transpose_b = false,_device =“/ job:localhost / replica:0 / task:0 / device:GPU:0”](linear / linear_model / x /重塑,线性/线性模型/ x /权重)]] [[节点:线性/梯度/线性/ linear_model / x / weighted_sum_grad / tuple / control_dependency_1 / _85 = _Recvclient_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,ten sor_name =“edge_184_linear / gradients / linear / linear_model / x / weighted_sum_grad / tuple / control_dependency_1”,tensor_type = DT_FLOAT,_device =“/ job:localhost / replica:0 / task:0 / device:CPU:0”]]

在处理上述异常期间,发生了另一个异常:

回溯(最近一次调用最后一次):文件“test.py”,第39行,在estimator.train中(input_fn = input_fn,steps = 1000)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py“,第302行,列车损失= self._train_model(input_fn,hooks,saving_listeners)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py“,第783行,_train_model _,loss = mon_sess.run([estimator_spec.train_op,estimator_spec.loss])文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py“,第521行,运行run_metadata = run_metadata)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py“,第892行,运行run_metadata = run_metadata)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,第967行,在运行中提高six.reraise(* original_exc_info)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ six.py“,第693行,重新加注值Fil Ë“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py”,第952行,在运行中返回self._sess.run(* args,** kwargs)文件“C: \ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py“,第1024行,运行run_metadata = run_metadata)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ training \ monitored_session.py“,第827行,在运行中返回self._sess.run(* args,** kwargs)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py“,第889行,运行run_metadata_ptr)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py“,第1120行,在_run feed_dict_tensor中, options,run_metadata)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,第1317行,在_do_run选项中,run_metadata)文件“C:\ Users \ Jeff \” Anaconda3 \ lib \ site-packages \ tensorflow \ python \ client \ session.py“,第1336行,在_do_call引发类型(e)(node_def,op,message)tensorflow .python.framework.errors_impl.InternalError:Blas GEMV启动失败:m = 1,n = 4 [[Node:linear / linear_model / x / weighted_sum = MatMul [T = DT_FLOAT,transpose_a = false,transpose_b = false,_device =“ / job:localhost / replica:0 / task:0 / device:GPU:0“](linear / linear_model / x / Reshape,linear / linear_model / x / weights)]] [[Node:linear / gradient / linear / linear_model / x / weighted_sum_grad / tuple / control_dependency_1 / _85 = _Recvclient_terminated = false,recv_device =“/ job:localhost / replica:0 / task:0 / device:CPU:0”,send_device =“/ job:localhost / replica:0 /任务:0 /设备:GPU:0“,send_device_incarnation = 1,tensor_name =”edge_184_linear / gradient / linear / linear_model / x / weighted_sum_grad / tuple / control_dependency_1“,tensor_type = DT_FLOAT,_device =”/ job:localhost / replica:0 / task:0 / device:CPU:0“]]由op'linear / linear_model / x / weighted_sum'引起,定义于:文件”test.py“,第39行,在estimator.train中(input_fn = input_fn,steps = 1000)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py”,第302行,在train loss = self._train_model(input_fn,hooks,saving_listeners)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py”,第711行,在_train_model中,标签,model_fn_lib.ModeKeys.TRAIN,self.config)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py”,第694行,在_call_model_fn中model_fn_results = self._model_fn (features = features,** kwargs)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ canned \ linear.py”,第348行,在_model_fn config = config)文件“ C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ canned \ linear.py“,第118行,_linear_model_fn logits = logit_fn(features = features)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ canned \ linear.py“,第70行,在linear_logit_fn features = features,feature_columns = feature_columns,units = units)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \站点包\ tensorflow \ python的\ feature_column \ featur e_column.py“,第321行,在linear_model列,builder,units,weight_collections,trainable))文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ feature_column \ feature_column.py“,line 1376,在_create_dense_column_weighted_sum中返回math_ops.matmul(tensor,weight,name ='weighted_sum')文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ ops \ math_ops.py”,第1891行,在matmul a,b,transpose_a = transpose_a,transpose_b = transpose_b,name = name)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ ops \ gen_math_ops.py”,第2436行,in _mat_mul name = name)文件“C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ op_def_library.py”,第787行,在_apply_op_helper中op_def = op_def)文件“C:\ Users \ Jeff \ anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ ops.py“,第2956行,在create_op中op_def = op_def)文件”C:\ Users \ Jeff \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ ops.py“,第1470行,在init self._traceback = self._graph._e中xtract_stack()#pylint:disable = protected-access InternalError(参见上面的回溯):Blas GEMV启动失败:m = 1,n = 4 [[Node:linear / linear_model / x / weighted_sum = MatMul [T = DT_FLOAT,transpose_a = false,transpose_b = false,_device =“/ job:localhost / replica:0 / task:0 / device:GPU:0”](linear / linear_model / x / Reshape,linear / linear_model / x / weights)]] [ [节点:线性/梯度/线性/ linear_model / x / weighted_sum_grad / tuple / control_dependency_1 / _85 = _Recvclient_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_184_linear / gradient / linear / linear_model / x / weighted_sum_grad / tuple / control_dependency_1”,tensor_type = DT_FLOAT,_device = “/作业:本地主机/复制:0 /任务:0 /装置:CPU:0”]]

1 回答

  • -1

    它的PermissionDeniedError:您应该从根目录运行此脚本,我现在可以看到 . 尝试并更新 .

相关问题