首页 > 解决方案 > ValueError: bad marshal data (unknown type code) 我在 unity 上运行一个关于自动模拟器的项目。运行 python 文件 drive.py model.h5 时出现错误:

问题描述

我尝试删除 pycache 文件,但它仍然无法正常工作,这是我的错误:

$ python drive.py model.h5
    2021-07-17 23:27:53.215529: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
    2021-07-17 23:27:53.215569: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
    2021-07-17 23:27:56.151293: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
    2021-07-17 23:27:56.151328: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
    2021-07-17 23:27:56.154808: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: Do-Duy-Truong
    2021-07-17 23:27:56.154983: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: Do-Duy-Truong
    2021-07-17 23:27:56.155278: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
    To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
    Traceback (most recent call last):
      File "C:\Users\bosst\Downloads\CNN-20210717T152725Z-001\CNN\drive.py", line 143, in <module>
        model = load_model(args.model)
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\saving\save.py", line 200, in load_model
        return hdf5_format.load_model_from_hdf5(filepath, custom_objects,
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\saving\hdf5_format.py", line 180, in load_model_from_hdf5
        model = model_config_lib.model_from_config(model_config,
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\saving\model_config.py", line 59, in model_from_config
        return deserialize(config, custom_objects=custom_objects)
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\layers\serialization.py", line 208, in deserialize
        return generic_utils.deserialize_keras_object(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\utils\generic_utils.py", line 674, in deserialize_keras_object
        deserialized_obj = cls.from_config(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\engine\sequential.py", line 432, in from_config
        layer = layer_module.deserialize(layer_config,
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\layers\serialization.py", line 208, in deserialize
        return generic_utils.deserialize_keras_object(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\utils\generic_utils.py", line 674, in deserialize_keras_object
        deserialized_obj = cls.from_config(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\layers\core.py", line 1005, in from_config
        function = cls._parse_function_from_config(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\layers\core.py", line 1057, in _parse_function_from_config
        function = generic_utils.func_load(
      File "C:\Users\bosst\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\keras\utils\generic_utils.py", line 789, in func_load
        code = marshal.loads(raw_code)
    ValueError: bad marshal data (unknown type code)

来源:https://nttuan8.com/bai-8-o-to-tu-lai-voi-udacity-open-source/

标签: python

解决方案


推荐阅读