python - 主管无法加载 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/
解决方案
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
推荐阅读
- java - 如何在 android 中使用 WiFi 打印机打印自定义尺寸的纸张?
- node.js - 使用 npm install 安装 node_packages 时出现代码 ELIFECYCLE 错误
- node.js - UnhandledPromiseRejectionWarning: MongoError: Unrecognized pipeline stage name: '$setWindowFields'
- c# - Dropbox.net 获取用户最喜欢的文件夹内容
- r - 更改集群 geom_col 中的填充顺序?
- encryption - 哈希的意义何在?
- angular - Angular - 错误的包版本?
- algorithm - 为什么在恢复最长递增子序列时需要祖先数组?
- wordpress - 手动调用 Gravity Forms Product Add-ons Plugin
- c - 在 C 中计算阶乘“x! = ?”的算法