Conda does not use package installed but using package from outside

Viewed 651

I got a problem when I using conda environment.

I create a environment simply by:

conda create -n NAME python==3.5

So there is a python 3.5 virtual environment. Then I enter into the virtual environment and install tensorflow-gpu with:

conda install tensorflow-gpu

Now I can see the tensorflow-gpu package along with the cudatoolkit and cudnn. But when I run a simple program it just failed to use gpu.I don't think it is a nvidia driver problem or package from different resources because it work in the old conda environment but when I create a new it failed.

More interesting is it will using the package(tensorrt and uff) from outside of the enviroment.

When I create a new environment with python 3.6.It works as expected using tensorflow-gpu and cannot import package which isnt installed in the environment.

Does some one know how to fix the problem?

Ubuntu 16.04

Tensorflow 1.8.0

Python 3.5 and 3.6

TensorRT 5.0.0.10

2 Answers

Well I had fixed it. This problem turn out to be the conda environment added a path from local and imported package from the local path instead of the environment.

If you run into the same problem.Try open python in your conda environment by:

python

and check the system path:

import sys
print(sys.path)

if there is a lib from outside just remove it using:

rm -r ~/PATH

This problem might origin from adding path unintentionally in some program.

Hope that helps.

This also happens if you use jupyter notebook. For example, if you have jupyter notebook installed and THEN create your environment, the jupyter notebook is OUTSIDE the environment and IGNORES all the packages you installed in your environment. I needed to install jupyter notebook into every environment I created to keep these errors from happening.

Related