首页 > 解决方案 > 主管无法加载 Cuda 库,路径不丢失,无需主管即可工作

问题描述

我有一个带有 Flask 的 python 应用程序,tensorflow-gpu ...,当我运行时运行没有问题:

gunicorn server:app -b localhost:8000

但是当我与主管一起运行它时,它给了我错误

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

我没有使用 virtualenv。

这是我的主管配置

[program:appserver]
command = gunicorn server:app -b localhost:8000
directory = /storage/appserver
user = root
stdout_logfile = /home/deploy/appserver/logs/gunicorn/gunicorn_stdout.log
stderr_logfile = /home/deploy/appserver/logs/gunicorn/gunicorn_stderr.log
redirect_stderr = True

我究竟做错了什么?

如果应用程序直接在命令行运行,为什么主管不能运行它?

我在 bashrc 有环境变量,就像我说的,如果我从命令行运行它就可以工作......

export PATH=/usr/local/cuda-9.0/bin/${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/


root@xxxxx:/home/xxxxx# echo $PATH
/usr/local/cuda-9.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
root@xxxxxx:/home/xxxxx# echo $LD_LIBRARY_PATH
/usr/local/cuda-9.0/lib64/

标签: pythontensorflowsupervisord

解决方案


supervisor不加载环境变量,它不依赖bash,所以必须直接在supervisor配置中加载环境变量。

这里以我的配置为例:

[program:hoot_api_ml]

user           = hoot
environment    = LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
directory      = /home/hoot/backend/hoot/ml
command        = gunicorn3 -c ../../conf/api_ml/gunicorn.py api:APP

autostart      = true
autorestart    = true

stderr_logfile = /var/log/hoot/api_ml_supervisor.err
stdout_logfile = /var/log/hoot/api_ml_supervisor.log

stopsignal     = INT

推荐阅读