【问题标题】:Import Keras in Django在 Django 中导入 Keras
【发布时间】:2020-11-11 10:20:34
【问题描述】:

这个问题与this 有关,但解决方案对我没有帮助。我决定开一个新帖子,因为这个话题太老了,建议的解决方案不起作用。

那么问题出在哪里:

当我尝试导入 keras 时,django 停止工作。当我在日志中重新启动 apache 时,我可以看到:

2020-11-11 10:01:07.783351: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2020-11-11 10:01:07.783383: 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.

这很好。但是,如果我尝试访问我的任何页面,它们就不会加载。日志中没有其他任何事情发生,没有任何错误或其他内容。

我做错了什么?

我的目标是使用经过训练的模型进行情绪分析。 我正在使用 ubuntu 18.04、python 3.6、django 3.1.2、Keras 2.4.3、tensorflow 2.3.1 开发远程虚拟机

【问题讨论】:

    标签: python django tensorflow keras


    【解决方案1】:

    你试过这些吗?尽管已经很老了,但有多种不同的解决方案似乎对其他人有用。

    https://serverfault.com/questions/844761/wsgi-truncated-or-oversized-response-headers-received-from-daemon-process

    【讨论】:

    • 谢谢,将WSGIApplicationGroup %{GLOBAL} 添加到 apache 配置文件中,终于可以工作了。
    • 听到这个消息超级高兴! :) 祝你好运!
    【解决方案2】:

    尝试卸载 TensorFlow 看看会发生什么

    【讨论】:

    • 它给了我这个错误ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
    • 嗯,问题是我目前也在 Django 中导入 Keras,它可以工作,唯一不同的是 tensorflow==2.2 和 Python 3.7.2。尝试安装更高版本的 python,因为 Keras 2.4.3 需要 Python 3.6+。
    • 没用。在日志中,在我在问题中发布的 tensorflow 日志之后打印了这一行 [Wed Nov 11 14:22:53.717872 2020] [wsgi:error] [pid 11996:tid 139696462083840] [client] Truncated or oversized response headers received from daemon process 'myappssl': /var/www/django/myapp/myapp/wsgi.py... 它是什么?
    猜你喜欢
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 1970-01-01
    相关资源
    最近更新 更多