Tensorflow path-performance installation - python

I've noticed that upon running my tensorflow, I have a spike on first few runs on start-up
upon searching on the internet, I came into this blog
the replies and official documents got me even more confusing on which installation is best for performance.
Is it
Conda
pip
docker
some others that are not listed?
My current setup is windows 10 laptop with GTX965M, tensorflow installation accordingly to this guide
Another weird thing, my conda installation is only able to install tensorflow 1.8 for some reason. Upon running the code conda update tensorflow, it returns latest version has been installed. But I can install tensorflow 2 by stating conda install tensorflow=2. Is this normal? If not what could be the issue? (I have all the packages updated before 'updating/installing' tensorflow. Doesn't help.)

As per my knowledge creating a virtual environment in anaconda and install the Tensorflow in virtual environment has advantages.
Please refer to this SO Answer for the advantages and steps to create virtual environment.
Upon running the code conda update tensorflow, it returns latest
version has been installed. But I can install tensorflow 2 by stating
conda install tensorflow=2. Is this normal?
Yes, this is a normal behavior.
Google Colab is an easy way to learn and use TensorFlow. It's a Jupyter notebook environment that requires no setup to use and runs entirely in the cloud.

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.

Problem with TensorFlow 2.0 / Anaconda: unable to create process using 'path'

I have been using TF2.0 in Anaconda without any problems until yesterday. My pc had to be rebooted for Windows 10 x64 updates and Avast updates. From that point on, the Jupyter Notebook of the environment I created for TF did not open. After a few attempts I decided to reinstall Anaconda. I can use the base environment without issues but when I create an additional one and install TensorFlow, pip stops working. I can open Jupyter Notebook but TF won't work. This is what happens when I execute pip in the Anaconda Prompt:
(base) C:\Users\ABCD>conda info --envs
# conda environments:
#
base * C:\Users\ABCD\anaconda3
pyt3-TF2.0 C:\Users\ABCD\anaconda3\envs\pyt3-TF2.0
test1 C:\Users\ABCD\anaconda3\envs\test1
(base) C:\Users\ABCD>conda activate test1
(test1) C:\Users\ABCD>pip
Unable to create process using 'C:\Users\ABCD\anaconda3\envs\test1\python.exe C:\Users\ABCD\anaconda3\envs\test1\Scripts\pip-script.py '
(test1) C:\Users\ABCD>
When I execute pip in the base environment everything works fine. All the software is installed and updated to the latest stable versions. This is the code that I use to create and install TensorFlow:
conda create --name test1 python=3
conda activate test1
conda install tensorflow
I tried different approaches such as downgrading, creating environments with different names, installing packages in a different order and installing older versions. I observed that the problem occurs when I install TF. The problem happened after the computer restarted due to updates while I was using TF. I googled a little and found that this might be a problem with the path. When I wanted to use the same name as the older environments I got 'errno 13 permission denied'.
I really would like to keep on working with TF so any help would be highly appreciated. Thanks in advance!
I fixed my issue and I want to share how I did it. The problem was Avast AV. The AV was not letting me install python or a package in the environment that I created. I temporarily deactivated the AV and I was finally able to install TF and Jupyter Notebook with no problems.

Python Anaconda reinstall

I had a working deep learning library on CPU Linux Mint ubuntu verion 18.3 with Anaconda 3.6 but something got hosed when I was tinkering around in Theano.
https://machinelearningmastery.com/setup-python-environment-machine-learning-deep-learning-anaconda/
Everything was working just fine until I wanted to tinker around with a few .py files with KERAS_BACKEND=theano python program.py and in an attempt to fix something not working in Theano, I did this command from the theano website
http://deeplearning.net/software/theano_versions/dev/requirements.html
conda install numpy scipy mkl <nose> <sphinx> <pydot-ng>
Not knowing what I am doing it almost seemed to pooch everything... And install Python 2.7 dependencies. Would anyone be able to give me a tip on how reset my deep learning library in anaconda 3.6 build???
If I do a conda list anaconda$ its a custom build 2.7 which was not intentional! Time to start learning how to do virtual sessions :)
Read the docs for uninstalling Anaconda
https://docs.anaconda.com/anaconda/install/uninstall
Do a conda install anaconda-clean
Then a anaconda-clean --yes
Then re-download the Anaconda 5.2 For Linux Installer and run thru
the steps. https://www.anaconda.com/download/#linux
I had a similar problem and just did:
conda install --revision 0
this gives me a fresh Anaconda installation, with the drawback of needing to install every package again. Hovewer, all environments created remain intact.
More on Anaconda revisions here: https://medium.com/#wilpat456/fix-broken-anaconda-environment-due-to-recent-package-download-9094fb0f3a04

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]

ImportError: No module named 'tensorflow' using anaconda + windows

Pip Installed tensor flow (CPU only... https://www.tensorflow.org/install/install_windows) in an anaconda environment, says it successfully installed but when I go to use tensor flow (with environment activated) it displays an error saying "ImportError: No module named 'tensorflow'".
However, After i installed pandas package, and it successfully runs. i ran an update to python=3.5 for the environment (because my anaconda is 2.7 version), and tried using this link https://github.com/tensorflow/tensorflow/issues/6136 for help also. Weird that other packages run but not tensor flow. Using a PC windows 10 with intel CPU and amd graphics. Any suggestions would be helpful.
First check which environment you are using right now.
If it helps open the anaconda navigator and see whether you have TensorFlow installed in the "installed" tab of that particular environment.
Check the following on jupyter noteook and see what python version you're using in that environment because the environment that you are using might have a different python version after all.
from platform import python_version
print(python_version())
If the versions are different, try removing the TensorFlow installation and reinstalling it according to your python version. environment and recreating the same environment pip install --ignore-installed --upgrade tensorflow=='version_for_your_requirement"
If the situation is still there, https://www.youtube.com/watch?v=tPq6NIboLSc see here the steps followed in the video. Though its a slightly different scenario, you will get the gist of it pretty quickly as to how we can make another environment for our work and about installing TensorFlow properly.
Tensorflow supports 64-bit Python version. Make sure you have installed 64-bit Python 3.5/3.6/3.8 version.
Install Tensorflow using following steps
#check current python version
python --version
#Create the virtual environment
conda create -n tf python=PYTHON_VERSION
#Activate the tf environment
conda activate tf
#Install Tensorflow
pip install tensorflow

Categories