2017-10-12 42 views
1

當我從命令行調用Tensforflow python腳本時,如預期的那樣工作正常。 但是,當我把它作爲一個cronjob,我得到這個錯誤:從cron調用Tensforflow python腳本不起作用

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

正如討論的in this question,cronjob與執行用戶不具有相同的環境。最簡單的解決方案是在cronjob中手動提供一個:

source $HOME/.bashrc && python my_script.py