Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Dimitris S

Getting started with Tensorflow (GPU edition)

Recommended Posts

Posted · Original PosterOP

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


Teacher: Does anyone have a thin ruler?

Students: No.

Teacher: Ok. Does anyone have a nail file.

Students: Why do you need a nail file?
Teacher: I have a staple I need to remove.

Student: Oh. I have a staple remover...

 

People don't want power drills, they want holes.

Link to post
Share on other sites
Posted · Original PosterOP
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 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.


Teacher: Does anyone have a thin ruler?

Students: No.

Teacher: Ok. Does anyone have a nail file.

Students: Why do you need a nail file?
Teacher: I have a staple I need to remove.

Student: Oh. I have a staple remover...

 

People don't want power drills, they want holes.

Link to post
Share on other sites
Posted · Original PosterOP
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 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


×