简体   繁体   English

在已经使用pip安装Tensorflow的情况下从源代码安装Tensorflow

[英]Installing Tensorflow from source when it is already installed using pip

My machine already have Tensorflow 8.0 installed using pip. 我的机器已经使用pip安装了Tensorflow 8.0。 I installed Tensorflow 9.0 from source to support cudnn 5. The thing is when I "import tensorflow" in python it still uses the pip installation. 我从源代码安装了Tensorflow 9.0以支持cudnn5。问题是,当我在python中“导入tensorflow”时,它仍然使用pip安装。

Can I tell python to import my new installation and ignore the pip installation? 我可以告诉python导入我的新安装,而忽略pip安装吗?

I want to keep the pip installation, because it is being used by other people (the machine is a server). 我想保留pip安装,因为其他人正在使用该安装(机器是服务器)。

Thanks, Dan 谢谢,丹

You can try one of these (solution 2 is the one I prefer) 您可以尝试其中之一(解决方案2是我更喜欢的一种)

1) Install only for your user: 1)仅为您的用户安装:

sudo pip install --user /tmp/tensorflow_pkg/tensorflow-0.9.0-py2-none-any.whl

2) Create a virtual environment to isolate it from your system install: 2)创建一个虚拟环境以将其与系统安装隔离开:

Tensorflow anaconda-installation Tensorflow Anaconda安装

3) Add the Tensorflow 9.0 to the sys.path list as in: 3)将Tensorflow 9.0添加到sys.path列表中,如下所示:

import sys
sys.path.insert(0, 'path/to/thensorflow_9')
import tensorflow
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM