在咱們正確配置了Keras使用GPU,並在Terminal中運行一切順利的的時候,轉到Pycharm或者Eclipse中運行有可能會出現「nvcc not found on the $PATH」.這是爲何呢?
引用下面一段話或許你們會明白:linux
you should probably know that all environment variables are inherited. When you define environment variable in your .bash_profile it becomes available in your terminal (bash), and in all processes that will be started from terminal (These processes will be children for the bash process). That's why you are getting expected values when running your script from within the terminal.bash
You start PyCharm not from a terminal, so it doesn't inherit PATH. And so do Python or venv (they launched from PyCharm).session
To solve your issue you have 3 options here: just start PyCharm from terminal or move PATH variable definition from .bash_profile to session init scripts (PATH will be defined system-wide) or Duplicate your PATH in PyCharm's run configuration (it has such option over there)eclipse
Good luck!ide
在linux中全部的環境變量都是繼承過來的,若是咱們在.bash_profile中定義了一個環境變量,那麼它會在在終端以及全部從終端啓動的程序中生效。
可是若是Pycharm不是使用命令從終端啓動的,那麼他就不會繼承這一環境變量,因此咱們能夠經過從終端啓動Pycharm來解決這個問題,eclipse的狀況同樣。翻譯
Use "Tools | Create Command-line Launcher" in PyCharm. This lets you choose the name of the script that will be used to start PyCharm.繼承