我在尝试运行这个Kaggle Jupyter笔记本的Python代码时,遇到了以下错误:
---------------------------------------------------------------------------InternalError Traceback (most recent call last)<ipython-input-40-be0fb0b18f3a> in <module> 1 #Defining Neural Network----> 2 model = Sequential() 3 #Non-trainable embeddidng layer 4 model.add(Embedding(max_features, output_dim=embed_size, weights=[embedding_matrix], input_length=maxlen, trainable=False)) 5 #LSTMc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 528 self._self_setattr_tracking = False # pylint: disable=protected-access 529 try:--> 530 result = method(self, *args, **kwargs) 531 finally: 532 self._self_setattr_tracking = previous_value # pylint: disable=protected-accessc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\keras\engine\sequential.py in __init__(self, layers, name) 105 """ 106 # Skip the init in FunctionalModel since model doesn't have input/output yet--> 107 super(functional.Functional, self).__init__( # pylint: disable=bad-super-call 108 name=name, autocast=False) 109 base_layer.keras_api_gauge.get_cell('Sequential').set(True)c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 528 self._self_setattr_tracking = False # pylint: disable=protected-access 529 try:--> 530 result = method(self, *args, **kwargs) 531 finally: 532 self._self_setattr_tracking = previous_value # pylint: disable=protected-accessc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\keras\engine\training.py in __init__(self, *args, **kwargs) 287 self._steps_per_execution = None 288 --> 289 self._init_batch_counters() 290 self._base_model_initialized = True 291 c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 528 self._self_setattr_tracking = False # pylint: disable=protected-access 529 try:--> 530 result = method(self, *args, **kwargs) 531 finally: 532 self._self_setattr_tracking = previous_value # pylint: disable=protected-accessc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\keras\engine\training.py in _init_batch_counters(self) 295 # `evaluate`, and `predict`. 296 agg = tf.VariableAggregation.ONLY_FIRST_REPLICA--> 297 self._train_counter = tf.Variable(0, dtype='int64', aggregation=agg) 298 self._test_counter = tf.Variable(0, dtype='int64', aggregation=agg) 299 self._predict_counter = tf.Variable(c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\variables.py in __call__(cls, *args, **kwargs) 266 return cls._variable_v1_call(*args, **kwargs) 267 elif cls is Variable:--> 268 return cls._variable_v2_call(*args, **kwargs) 269 else: 270 return super(VariableMetaclass, cls).__call__(*args, **kwargs)c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\variables.py in _variable_v2_call(cls, initial_value, trainable, validate_shape, caching_device, name, variable_def, dtype, import_scope, constraint, synchronization, aggregation, shape) 248 if aggregation is None: 249 aggregation = VariableAggregation.NONE--> 250 return previous_getter( 251 initial_value=initial_value, 252 trainable=trainable,c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\variables.py in <lambda>(**kws) 241 shape=None): 242 """Call on Variable class. Useful to force the signature."""--> 243 previous_getter = lambda **kws: default_variable_creator_v2(None, **kws) 244 for _, getter in ops.get_default_graph()._variable_creator_stack: # pylint: disable=protected-access 245 previous_getter = _make_getter(getter, previous_getter)c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\variable_scope.py in default_variable_creator_v2(next_creator, **kwargs) 2660 shape = kwargs.get("shape", None) 2661 -> 2662 return resource_variable_ops.ResourceVariable( 2663 initial_value=initial_value, 2664 trainable=trainable,c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\variables.py in __call__(cls, *args, **kwargs) 268 return cls._variable_v2_call(*args, **kwargs) 269 else:--> 270 return super(VariableMetaclass, cls).__call__(*args, **kwargs) 271 272 c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, variable_def, import_scope, constraint, distribute_strategy, synchronization, aggregation, shape) 1600 self._init_from_proto(variable_def, import_scope=import_scope) 1601 else:-> 1602 self._init_from_args( 1603 initial_value=initial_value, 1604 trainable=trainable,c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py in _init_from_args(self, initial_value, trainable, collections, caching_device, name, dtype, constraint, synchronization, aggregation, distribute_strategy, shape) 1743 self._update_uid = initial_value.checkpoint_position.restore_uid 1744 initial_value = initial_value.wrapped_value-> 1745 initial_value = ops.convert_to_tensor(initial_value, 1746 name="initial_value", 1747 dtype=dtype)c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\profiler\trace.py in wrapped(*args, **kwargs) 161 with Trace(trace_name, **trace_kwargs): 162 return func(*args, **kwargs)--> 163 return func(*args, **kwargs) 164 165 return wrappedc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types) 1564 1565 if ret is None:-> 1566 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) 1567 1568 if ret is NotImplemented:c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\tensor_conversion_registry.py in _default_conversion_function(***failed resolving arguments***) 50 def _default_conversion_function(value, dtype, name, as_ref): 51 del as_ref # Unused.---> 52 return constant_op.constant(value, dtype, name=name) 53 54 c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\constant_op.py in constant(value, dtype, shape, name) 269 ValueError: if called on a symbolic tensor. 270 """--> 271 return _constant_impl(value, dtype, shape, name, verify_shape=False, 272 allow_broadcast=True) 273 c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast) 281 with trace.Trace("tf.constant"): 282 return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)--> 283 return _constant_eager_impl(ctx, value, dtype, shape, verify_shape) 284 285 g = ops.get_default_graph()c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\constant_op.py in _constant_eager_impl(ctx, value, dtype, shape, verify_shape) 306 def _constant_eager_impl(ctx, value, dtype, shape, verify_shape): 307 """Creates a constant on the current device."""--> 308 t = convert_to_eager_tensor(value, ctx, dtype) 309 if shape is None: 310 return tc:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\framework\constant_op.py in convert_to_eager_tensor(value, ctx, dtype) 103 except AttributeError: 104 dtype = dtypes.as_dtype(dtype).as_datatype_enum--> 105 ctx.ensure_initialized() 106 return ops.EagerTensor(value, ctx.device_name, dtype) 107 c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\eager\context.py in ensure_initialized(self) 534 opts = pywrap_tfe.TFE_NewContextOptions() 535 try:--> 536 config_str = self.config.SerializeToString() 537 pywrap_tfe.TFE_ContextOptionsSetConfig(opts, config_str) 538 if self._device_policy is not None:c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\eager\context.py in config(self) 962 """Return the ConfigProto with all runtime deltas applied.""" 963 # Ensure physical devices have been discovered and config has been imported--> 964 self._initialize_physical_devices() 965 966 config = config_pb2.ConfigProto()c:\users\kim\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\eager\context.py in _initialize_physical_devices(self, reinitialize) 1291 return 1292 -> 1293 devs = pywrap_tfe.TF_ListPhysicalDevices() 1294 self._physical_devices = [ 1295 PhysicalDevice(name=d.decode(), device_type=d.decode().split(":")[1])InternalError: Cannot dlopen all CUDA libraries.
我该如何解决这个问题?
回答:
好的,我尝试了几种方法,在安装了tensorflow-gpu之后,它工作了。也许这也可以帮助其他人解决这个问题:
pip install tensorflow-gpu