Why isn't tensorflow or pytorch recognized after I restart conda virtual environment? - tensorflow

Last night, I made a virtual environment and the only installs I made were as follows:
conda install jupyter
conda install notebook
pip install transformers
And I was able to run huggingface transformers perfectly, but today I reactivate my conda virtual environment and I'm met with this puzzling error:
And this is the runtime error
I even tried making a new virtual environment with the same depencies and today I got these errors upon performing pip install transformers
And this in jupyter notebook

HuggingFace Transformers need to be installed in conjunction to either Tensorflow or Pytorch. From the HuggingFace installation instructions:
First you need to install one of, or both, TensorFlow 2.0 and PyTorch.
So you should choose which machine learning platform you like more and install that too in your virtual environment.
For Tensorflow either pip install tensorflow or pip install tensorflow-gpu and for Pytorch pip install torch torchvision
For example, in a fresh environment, the following instructions should make your errors disappear (I'm assuming you have a GPU):
conda install jupyter
conda install notebook
pip install tensorflow-gpu
pip install transformers

Related

Difficulty updating keras/tensorflow on mac

I am working on a jupyter notebook script which I used last year to train a neural network.
When I try to import the keras tokenizer:
from keras.preprocessing.text import Tokenizer
I receive this error
I have seen other posts which suggest that I need to update tensorflow. My anaconda environment tells me I have 1.13.1 installed. But when I try to update tensorflow-base to 1.15 in the anaconda navigator, I receive this error:
I can update tensorflow from my command line using:
conda install tensorflow=1.15.0
But this doesn't update tensorflow in my anaconda environment and the error persists in my notebook.
Any help would be much appreciated! As you can probably tell, I am a novice python user.
The error says some packages needed to update Tensorflow/Andaconda requires Python 3.11 or newer. Since not all of the error log can be seen however, I would upgrade to python 3.7 to be safe. You can download this from the official page: https://www.python.org/downloads/
If the problem persists, try using pip to update the packages(In bash) :
pip install tensorflow
pip install conda
If you get an error while using pip, try:
pip3 install tensorflow
pip3 install conda
This same method can be used to update keras:
pip install keras
or if that does not work:
pip3 install keras
If pip is not recognized at a command, Python 3.7 is not added to path. I do not have experience with macOS, but this article should go into enough depth.
https://realpython.com/add-python-to-path/#how-to-add-python-to-path-on-linux-and-macos

I installed tensor flow from in command prompt and I cant access in anaconda

I have downloaded the tensor flow using pip install tensorflow but when I try to access in the anaconda promy it show no module name tensor flow.
Is asking again to download the TensorFlow.
Kindly help me!
You should not mix conda and pip installations.
First, check if the pip installation you did was successful: run pip freeze and look at the output. If tensorflow is in the list, it was successful.
Then, if it's installed, uninstall it via pip: pip uninstall tensorflow.
Finally, you can install tensorflow through conda by running conda install tensorflow.

Installed pytorch with conda which changed my TF version to 1.13.0 now conda install tensorflow-gpu=2.0 not working?

Like I said in title I installed pytorch with conda install and that downgraded my tensorflow version to 1.13.0 and now conda install tensorflow-gpu=2.0 is not working how can I get the command to execute?
I would suggest that you try to install tensorflow with pip. pip install -U tensorflow-gpu
https://www.tensorflow.org/install/gpu
I am using pytorch, but my env has pytorch 1.2 + tensorflow 2.1
You should have installed pyTorch in another virtual environment but since now it has been installed.
I would recommend you to create a virtual environment and install TF plus other libraries in it. Because I am sure you would not use both PyTorch and TF in the same program for ML.

Tensorflow version different in conda env & jupyter notebook

I created a conda env and installed tensorflow 1.4
pip install tensorflow==1.4
This installed, and from within the environment, when i type
import tensorflow as tf
tf.__version__
it prints '1.4.0'
Now, i open jupyter notebook from the same environment, and when i type the same in the notebook, it gives me 1.10.0
How is this possible? Jupyter notebook should take the same libraries within which it is running. How does it have a different version of tensorflow
And btw I'm concerned with this because i wanna use 1.4.0 in my notebook
These are the questions I ask myself in situations like this, and they usually resolve my issue:
Was the kernel of my notebook running while I pipped? Shut down and restart.
Are pip and conda sharing PATH, et cetera? I don't take it for granted that my pip is modifying my conda env. You can check with these commands.
Your conda env is created, but is it active? You list created envs with these, and you can activate/deactivate with these.
Besides checking all of these, where am I launching jupyter from? I like to install jupyter with a simply pip install jupyter and that could add jupyter to the command line globally. Anaconda navigator/command line reliably launches the jupyter that lives in your Anaconda distribution.
To add to Charles Landau:
You likely installed tensorflow in parallel with pip and with conda.
Within your env, just check with pip list tensorflow and conda list tensorflow. Most likely you will see two different versions.
To be consistent do:
pip unistall tensorflow to keep only one.

tensorflow installation error in Window + anaconda

i tried to install tensorflow in my anaconda by creating a virtual env
conda create -n tensorflow python=3.5
but after i type y, nothing happened. How can i fix this?
So what you did is creating an environment called tensorflow, you need to install it as well
you can do either
conda install tensorflow
or
pip install tensorflow