Why am I having errors while installing Tensorflow? - python

I had issues with my Tensorflow and had to re-install it. In order to ensure I do not make mistakes like I have done before, I followed Jeff Heaton tutorials (available here) for installing Tensorflow for CPU. However, on executing the command: conda env create -v -f tensorflow.yml, I get some massive error (please see details here!).
Kindly show me where I am getting it wrong.
I have tried both 2020 and 2019 versions of anaconda. Using Miniconda did not help either.
Thank you very much.

Follow the installation instructions on Anaconda's website for TensorFlow for CPU:
conda create -n tensorflow_env tensorflow
conda activate tensorflow_env

Pls, retry with anaconda
I hope it helps and to you
Download the latest version of anaconda, and start "Anaconda promt(anaconda)", then write this in Anaconda terminal
pip install tensorflow
And for test
python3
import tensorflow
If you haven't got errors, You succefully install library.

Related

Having trouble installing Pytorch on Windows

I have tried install pytorch with pip but there is no package fit for my environment. I use Python 3.11.2. Then I downloaded anaconda and installed pytorch successfully. However, when I imported torch in python, it said there is no such module.
I followed many tutorials by restart my laptop, created conda enviroment and install pytorch there. Nothing worked.
Anyone having similar problems?
That's not clear for your problem. I think you may show the process of how you installed pytorch by conda.
You can use conda list pip list to show your package installed.
The problem in anaconda may be you install pytorch in your specific env, but when you open your ide (i.e. vscode, pycharm) you choose the base env. You may try run your code in your terminal by conda activate xxxx then python3 then import torch.

TensorFlow (any version > 2.5.0) on M1 Mac: No code completion in PyCharm

I am using JetBrain's PyCharm IDE to work with TensorFlow on a M1 Mac machine.
I have installed TensorFlow using the following commands in the given order:
conda create -n data-science -y python=3.9
conda activate data-science
conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
For installing Conda, I followed Apple's official documentation
I can import TensorFlow without problems; the version number it prints is 2.8.0.
However, I am not getting any code completion suggestions.
When typing tensorflow.keras.l, it should suggest layers, or losses.
As the attached screenshot shows, I am not getting anything usable:
I have restarted the IDE, invalidated any caches, re-indexed the project, and re-created the environment from scratch multiple times, all to no avail. Other suggestions are working as expected (such as the os.path.join line in the screenshot). What puzzles me is that, in another project on the very same machine (M1 Mac), I am using TensorFlow 2.5.0, which gives me the desired code suggestions.
The inability to get code suggestion for more recent TensorFlow versions has stopped me from updating to, e.g., version 2.8.0. What are your suggestions to solve this issue?
For code completion you can follow below workaround
from tensorflow import keras
if typing.TYPE_CHECKING:
from keras.api._v2 import keras
For more details please refer here.

How to install SciPy on MacOS with M1

I am trying to install keras in a virtual env but was getting errors. I then tried to install it following the steps on this site: https://www.tutorialspoint.com/keras/keras_installation.htm. The first few installs work but when I ran pip install SciPy I kept getting errors. I found others have encountered issues with installing SciPy on apple silicon online and saw a few recommendations but haven't been able to get anything to work so far. Can anyone help me out? Will I just have to wait for SciPy to release a compatible version?
If its helpful, I am working on a M1 processor with MacOS 11.3.1, and using python 3.8.2.
I have tried using homebrew as outlined here:
https://stackoverflow.com/a/66536896/16461391.
I have tried using miniforge as outlined here:
https://stackoverflow.com/a/66768260/16461391.
I managed to find a way to do it. I'm just posting my answer here in case someone else is stuck on the problem.
The way I did it was by running in terminal:
conda install -c conda-forge keras
then I checked it was installed in my condo env using the anaconda navigator, then I opened the condo environment in pycharm by following the steps here:
https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html.

Tensorflow and Cuda for Unity ML-Agents WITHOUT a GPU

I am trying to use tensorflow for use with unity ml-agents. I followed the setup instructions which can be found here as far as "creating the conda environment". I managed to run the conda create command succesfully, activate tensorflow, install tensorflow and finally to launch python.
But when I run this command "import tensorflow as tf" I get an error as a result of my machine having no GPU present. I am working on the assumption that using the CUDA_VISIBLE_DEVICES environment variable will solve this problem and force the use of the CPU but I'm not exactly sure how to input the variable.
Can anyone tell me exactly how this should appear in the environment variables interface? Or does anyone have any other idea about how to set this up properly?
Thanks In advance
Uninstall tensorflow
Pip uninstall tensorflow
or
pip uninstall tensorflow-gpu
depends upon what you have installed
then
pip install tensorflow
or if you want to install a specific version
pip install tensoflow==[version]

Installing TensorFlow in python 3.5 Anaconda distro conda env

What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.
The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.

Categories