简体   繁体   English

tensorflow gpu从systemd服务初始化失败

[英]tensorflow gpu failed init from systemd service

I'm trying to host flask API which is using tensorflow libraries.I installed tensorflow gpu library with CUDA and cudnn libraries.I manually checked with the following command which is working fine. 我正在尝试托管使用tensorflow库的flask API。我安装了带有CUDA和cudnn库的tensorflow gpu库。我使用以下命令手动检查了它是否正常。

/captcha/env/bin/gunicorn captcha:app -b 0.0.0.0:5124 -k gevent --worker-connections 1000

But when i add this systemd service im getting a tensorflow gpu error 但是当我添加这个systemd服务时,我得到了一个tensorflow gpu错误

systemd service 系统服务

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
PIDFile=/run/gunicorn/pid
User=root
Group=root
WorkingDirectory=/captcha/env
ExecStart=/captcha/env/bin/gunicorn captcha:app -b 0.0.0.0:5124 -k gevent --worker-connections 1000
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Error text in Log file: 日志文件中的错误文本:

Failed to load the native TensorFlow runtime. 无法加载本地TensorFlow运行时。

See https://www.tensorflow.org/install/install_sources#common_installation_problems 请参阅https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions. 出于某些常见原因和解决方案。 Include the entire stack trace above this error message when asking for help. 寻求帮助时,在此错误消息上方包括整个堆栈跟踪。

Can anyone point me where I'm doing wrong? 谁能指出我做错了什么?

I'm using PM2 to manage tensorflow-flask api process. 我正在使用PM2来管理tensorflow-flask api进程。

http://pm2.keymetrics.io/ http://pm2.keymetrics.io/

I Create a shell file with the following command as a content. 我使用以下命令作为内容创建外壳文件。

pm2 start run.sh

Systemd seems to strip all the environment variables and TensorFlow needs to know where to find Cuda. Systemd似乎剥离了所有环境变量,而TensorFlow需要知道在哪里可以找到Cuda。 Without a LD_LIBRARY_PATH it fails. 没有LD_LIBRARY_PATH,它将失败。

There are probably a handful of ways to do this, but this worked for me. 可能有几种方法可以执行此操作,但这对我有用。

[Service]
Environment=LD_LIBRARY_PATH=/usr/local/cuda/lib64
ExecStart=/path/to/your/app
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM