解决Keras在IDE集成环境中找不到nvcc

在我们正确配置了Keras使用GPU,并在Terminal中运行一切顺利的的时候,转到Pycharm或者Eclipse中运行有可能会出现“nvcc not found on the $PATH”.这是为什么呢?
引用下面一段话或许大家会明白:

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.

You start PyCharm not from a terminal, so it doesn't inherit PATH. And so do Python or venv (they launched from PyCharm).

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)

Good luck!

翻译一下:

在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.

参考:
http://stackoverflow.com/questions/21486528/environment-path-different-when-using-venv/21488010#21488010

http://stackoverflow.com/questions/38280081/how-can-i-launch-pycharm-from-terminal-to-use-it-with-ros

原文地址:https://www.cnblogs.com/zhanglianbo/p/6119500.html