当我从命令行调用我的Tensforflow python脚本时可以正常工作。 但当我把它称为cronjob时,我收到了这个错误:
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
我知道问题是什么,它与环境路径有关,更多可以在这里找到:After building TensorFlow from source, seeing libcudart.so and libcudnn errors但我不知道如何解决它所以我可以从cronjob调用python脚本。
答案 0 :(得分:0)
正如in this question所述,cronjob与执行用户的环境不同。最简单的解决方案是在cronjob中手动提供一个:
source $HOME/.bashrc && python my_script.py