在咱们正确配置了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.继承