Jump to content

Getting started with Tensorflow (GPU edition)

Dimitris S

I Want to Install tensorflow-gpu on my computer.

What have I done so far:

1) Installed the latest version of anaconda

2) Added C:\Users\user\Anaconda3 to PATH
3)
Created environment for tensorflow with   conda create --name tensorflow

4) Activated said environment with   activate tensorflow

5) Installed tensorflow-gpu package with  conda install tensorflow-gpu

6) Tried to import tensorflow as tf and got this error: 
 

Screenshot_17.jpg.2761ccf7ec5d1c6e44a6236c161509e4.jpg

Can anybody point me in the right direction?

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

I have tried it already. Nothing changed. Not ever the error message

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Dimitris S said:

I have tried it already. Nothing changed. Not ever the error message

What you do with Conda is install python into your Conda environment.

When you use a global Python install, but local library installs, you end up having to do all sorts of weird things to get your libraries to import, like:

import sys

sys.path.append("path\to\library")

import libraryA
import libraryB
import libraryC
...:
import HowManyDoINeed 

There are a few caveats with that method, however.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, straight_stewie said:

What you do with Conda is install python into your Conda environment.

When you use a global Python install, but local library installs, you end up having to do all sorts of weird things to get your libraries to import, like:


import sys

sys.path.append("path\to\library")

import libraryA
import libraryB
import libraryC
...:
import HowManyDoINeed 

There are a few caveats with that method, however.

Can u briefly describe what is the solution in steps? I have trouble understanding fully what are you saying

Link to comment
Share on other sites

Link to post
Share on other sites

21 minutes ago, Dimitris S said:

Can u briefly describe what is the solution in steps? I have trouble understanding fully what are you saying 

Python's import system basically only uses relative filepaths. Ostensibly this means that all of your libraries, like tensorFlow or numpy expect to be installed to your python installs root location, and python expects that as well.

The problem you are experiencing is because you are using a global python install: i.e. you downloaded python from python.org, and installed it, and added it to your PATH variable. But, you are using local library installs. Ergo, python doesn't know where the libraries are, and the libraries don't know where python is.

There are two ways easy ways to fix this:

  • Stop using Conda. I mean, do you really need to have separate environments for every project you're working on? Instead, you can use pip to install your packages into your global python installation, and then they will work from everywhere with few problems.
  • Use Conda, but also install python into every Conda environment. This way, all of your libraries and your python install are in the same place. This could be finicky, I haven't tried it myself.

The third way is what I described above. This basically tells python to switch it's "system path" from whatever is in your PATH variable that points to your pythons root directory, to whatever path you put there, and then you can import things from that folder.

I know that all of the science packages really try very hard to push you into using Conda, but you do not need to use it. Most or all of the packages available on Conda are also available on pip. Installing tensorFlow globally is as easy as typing "pip install tensorflow" at the command prompt. (unless you're running linux, then: "sudo pip install tensorflow")

EDIT:: For the Cuda enabled version of tensorFlow, the commands would be "pip install tensorflow-gpu" and "sudo pip install tensorflow-gpu" respectively.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, straight_stewie said:

Python's import system basically only uses relative filepaths. Ostensibly this means that all of your libraries, like tensorFlow or numpy expect to be installed to your python installs root location, and python expects that as well.

The problem you are experiencing is because you are using a global python install: i.e. you downloaded python from python.org, and installed it, and added it to your PATH variable. But, you are using local library installs. Ergo, python doesn't know where the libraries are, and the libraries don't know where python is.

There are two ways easy ways to fix this:

  • Stop using Conda. I mean, do you really need to have separate environments for every project you're working on? Instead, you can use pip to install your packages into your global python installation, and then they will work from everywhere with few problems.
  • Use Conda, but also install python into every Conda environment. This way, all of your libraries and your python install are in the same place. This could be finicky, I haven't tried it myself.

The third way is what I described above. This basically tells python to switch it's "system path" from whatever is in your PATH variable that points to your pythons root directory, to whatever path you put there, and then you can import things from that folder.

I know that all of the science packages really try very hard to push you into using Conda, but you do not need to use it. Most or all of the packages available on Conda are also available on pip. Installing tensorFlow globally is as easy as typing "pip install tensorflow" at the command prompt. (unless you're running linux, then: "sudo pip install tensorflow")

EDIT:: For the Cuda enabled version of tensorFlow, the commands would be "pip install tensorflow-gpu" and "sudo pip install tensorflow-gpu" respectively.

Thanks for the detailed explanation. I appreciate it

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×