How to update Tensorflow on mac? - python-3.x

My current Tensorflow version is 0.10.0. I need to update it to latest version.Latest one is 1.0.0.Is there any method that I can use in
terminal?
This is the python code which I used to find version
import tensorflow as tf;
print(tf.__version__);

If you are using anaconda;
>conda update tensorflow
If you are using pip;
>pip install tensorflow --upgrade
If you want to force install a specific version on conda;
>conda install tensorflow=1.0.0
If you want to force install a specific version on pip;
>pip install 'tensorflow==1.0.0' --force-reinstall

In anaconda cloud, first pick a channel which has the latest version of tensorflow binary. The latest versions are usually available at the channel conda-forge
conda update -f -c conda-forge tensorflow
This will upgrade your installation to the very latest version available. As of this writing version 1.4.0-py36_0

Related

How to install Tensorflow-Federated 0.28.0 on win10?

I need some function or api which belongs to the newest version of Tensorflow Federated. According to the tutorial of official website, I type the following to install the newest version.
pip install --upgrade pip
pip install --upgrade tensorflow-federated
Unfortunately, when the installation has been finished, the version is 0.17.0, which was published in 2020. Therefore, I just want to know how to install Tensorflow-Federated 0.28.0 on win10.
I have moved to Linux System, and everything is ok now. The win 10 platform can't download the newest version.

How to install tensorflowgpu-version with lower(compatible) version of cudatoolkit and cudnn

Every time I install tensorflow-gpu on anaconda its automatically installing tensorflow-gpu with
the most updated available version of cudatoolkit and cudnn evens if it's not compatible with graphic
card and cuda which I have already installed on my computer, which creates a big problem later on in
simulations.
For example I have RTX3060 and I am installing tensorflow-gpu 2.5.0, I have already installed
cuda 11.1 but when I install it with anaconda as
"conda install tensorflow-gpu=2.5.0"
It will install cudatoolkit 11.3.x... and the most advanced available cudnn
You can install tensorflow-gpu with the following commands with compatible cudatoolkit and cudnn versions.
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
#It is recommended to use pip to install TensorFlow since it is officially released to PyPI.
python3 -m pip install tensorflow-gpu==2.5.0
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
For step-by-step instructions, please refer to this link.

Unable to install tensorflow using conda with python 3.8

Recently, I upgraded to Anaconda3 2020.07 which uses python 3.8. In past versions of anaconda, tensorflow was installed successfully. Tensorflow failed to be installed successfully in this version.
I ran the command below;
conda install tensorflow-gpu
The error message that I received is shown below;
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- tensorflow-gpu -> python[version='3.5.*|3.6.*|3.7.*|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0|>=2.7,<2.8.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
The following specifications were found to be incompatible with your CUDA driver:
- feature:/win-64::__cuda==11.0=0
Your installed CUDA driver is: 11.0
Is there a conda command with the right parameters to get tensorflow installed successfully?
UPDATE:
TF is now compatible with Python 3.8
Tensorflow is not compatible with Python 3.8. See https://www.tensorflow.org/install/pip
You need to downgrade your python version :
conda install python=3.7
Create an environment with python 3.7 and then activate it:
conda create -n p37env python=3.7
conda activate p37env
And install tensorflow.
This worked for me, and found out the answer from the Anaconda user guide (under how to use a different python version: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python )
From the requirement page:
Python 3.8 support requires TensorFlow 2.2 or later.
So there is a verison of Tensorflow compatible with python 3.8.
The problem is that TensorFlow 2.2.0 is not available through conda on Windows, this should be the reason why you get PackagesNotFoundError when running
conda install tensorflow=2.2
EDIT 15/03/21
Tensorflow 2.3.0 is compatible with Windows
i think we have two options here
pip install tensorflow
or we can use another env of anaconda such as like this below
conda create -n tf tensorflow pydotplus jupyter
conda activate tf
Actually you can directly use pip inside anaconda prompt, after I tested it, I found the conda is capable with pypi, first run the anaconda prompt with administrator permission (in windows), then enter "conda update --all" to make sure all the packages are latest, finally enter "pip install tensorflow" to install (the new version of tensorflow already includes tensorflow-gpu).
Then using VS code to open an ipynb and run
import tensorflow as tf
tf.test.gpu_device_name()
everything looks good.
For more info please refer to Anaconda official docs: https://docs.anaconda.com/anaconda/ .
Latest development for tensorflow installation on anaconda.
https://anaconda.org/anaconda/tensorflow
https://anaconda.org/anaconda/tensorflow-gpu
9 days ago, Anaconda uploaded a new tensorflow v2.3 package. Anaconda3 2020.07 (uses python v3.8) users can easily upgrade to tensorflow v2.3 with the following commands;
conda install -c anaconda tensorflow
conda install -c anaconda tensorflow-gpu
I have personally tested that the installation worked successfully.
The other answers for this question have now become obsolete.
Expanding upon William's answer here with more explicit instructions and caveats. Pip is the recommended way to install latest version of tensorflow as per tensorflow's installation instructions -- "While the TensorFlow provided pip package is recommended, a community-supported Anaconda package is available."
Here is the code that uses pip to do the installation in a Conda environment:
conda create -n env_name python=3.8
conda activate env_name
conda install pandas scikit-learn matplotlib notebook ##installing usual Data Science packages that does include numpy and scipy
pip install tensorflow
python -c "import tensorflow as tf;print(tf.__version__)" ##checks tf version
In general, we should be careful while mixing two package managers (conda and pip). So, it is suggested that:
Only after conda has been used to install as many packages as possible
should pip be used to install any remaining software. If modifications
are needed to the environment, it is best to create a new environment
rather than running conda after pip.
For an example, if we would like to install seaborn in the just created env_name environment, we should:
conda create --name cloned_env --clone env_name
conda activate cloned_env
conda install seaborn
Once we check the cloned_env environment is working fine, we can delete the env_name environment.
I was running into the same issue in conda prompt for Python 3.8.5 and fixed it using a Python wheel instead. Here are the steps:
Open conda prompt and install pip if you don't have it already: python -m pip install --upgrade pip
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp38-cp38-win_amd64.whl
Note: If you need a CPU specific tensorflow, use this wheel: https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp38-cp38-win_amd64.whl
I just downgraded python to 3.7 as tf is not avialable to 3.8 version also I cannot use virtualenv for code that's why
The only working answer for me is:
conda install -c conda-forge tensorflow
It appears that tensorflow 2.5 on GPU has issues with spyder. So, I made new environment and installed tensorflow gpu as suggested by anaconda. Now I have to use either prompt or jupyter . At least it works
For macos users I suggest create an environment with python 3.7 and install tensorflow there.
You can run these commands too:
conda create -n new_env_name python=3.7
conda activate new_env_name
I had a similar problem in Anaconda Spyder. Here was my solution (In the Anaconda Console):
conda install pip
pip install tensorflow ==2.2.0

I can't install basemap package

I tried to work with Basemap packages in Python 3.x but, when I try to install the packages in my IDE Pycharm, it gives me this error:
Could not find a version that satisfies the requirement Basemap (from versions: )
No matching distribution found for Basemap
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Anyone knows how can I do to install that packages correctly?
(Python 3.x, Pycharm, Windows 10)
You can read on their github that the package was deprecated and they recommended to use cartopy instead:
Source:
https://github.com/matplotlib/basemap
⚠️ Warning: this package is being deprecated in favour of cartopy.
I also ran into a similar problem and the above two solutions did not work for me.
And as you can see here https://github.com/jakevdp/PythonDataScienceHandbook/issues/72#issuecomment-301008464
It is no longer possible to install it via pip, rather try this:
conda install -c conda-forge basemap
You can try to install basemap using precompiled windows binaries.
Download the basemap whl file that is most applicable to you from
here.
Run pip install path_to_the_downloaded_whl on pycharm terminal.
You can install basemap library easily by conda. First of all, you must install conda, then you can create a virtual environment by conda create -n bm python=3.6 (you can use any word you like to replace bm) and activate it by conda activate bm . When command line starts with (bm), you can run conda install basemap to automatically install the library. After that, usually you can use basemap in your python code.
Good luck.

Installing Blocks on Linux

I'm trying to install Blocks on my Linux machine and I have some troubles. How can I fix this? I'm doing the following steps:
Installing Anaconda for python2.
Theano depends on numpy 1.10.1 version. If at this step I will run import theano in python shell then it will work perfectly.
Okay, it's time for Blocks. I'm installing stable version using pip install --user git+git://github.com/mila-udem/blocks.git \
-r https://raw.githubusercontent.com/mila-udem/blocks/master/requirements.txt
After this step if I import theano it gives the following: RuntimeError: module compiled against API version a but this version of numpy is 9.
I looked at requirements.txt and see that Blocks depends on numpy 1.9.3.
I uninstalled Theano, Blocks, downgraded numpy using conda install numpy=1.9.3, then just run again pip install --user git+git://github.com/mila-udem/blocks.git \
-r https://raw.githubusercontent.com/mila-udem/blocks/master/requirements.txt and still while importing theano it gives me RuntimeError: module compiled against API version a but this version of numpy is 9.
How can I overcome this problem?
This could be a problem with the Anaconda distribution. You could try updating all of Anaconda via conda update conda and conda update --all. You could also try changing Blocks requirements.txt to refer to numpy 1.10.1 since it's likely that Blocks won't care about the changes from 1.9 to 1.10.
– Daniel Renshaw

Resources