I am using jetson NX xavier kit having cuda 10.2.89, open Cv 4.1.1 and tensorRT 7.1.3 . Trying to install pytorch. Tried installing with this line
conda install pytorch torchvision cpuonly -c pytorch
but when i write this line
import torch
It throws an error by saying that module not installed.
How I can verify if pytorch has been installed correctly.
Try this one
conda install -c pytorch pytorch
After executing this command, you need to enter yes(if prompted in the command line) for installing all the related packages. If there is no conflict while installing the libraries, the PyTorch library will be installed.
To check if it is properly installed or not, type the command python in your command line and type import torch to check if it is properly installed or not.
I am using an existing model to train a CRNN model which is based on Tensorflow and Keras. I am using anaconda-navigator to train the model.
When the model is being trained, it does not seem to use GPU as my GPU usage is at 5-6%.
I am attaching images of top -i command, Nvidia Xserver, and also my gpu is not being picked up by Tensorflow as tf.test.gpu_device_name() only shows CPU as shown in the below screenshot tf.test.gpu_device_name()
Tensorflow and Keras Versions in anaconda
top -i output
After looking at your TensorFlow and Keras versions in anaconda, i found there is a tensorflow-gpu package missing. It looks like you have only installed TensorFlow CPU version and not the GPU version. If you had installed the GPU version of TensorFlow, then the anaconda navigator would also show a metapackage of TensorFlow GPU library.
That is the reason why you don't see the details of your GPU with the command tf.test.gpu_device_name()
TensorFlow GPU will automatically load the CUDA libraries corresponding to your GPU.
Since you are using anaconda environment install the GPU version as follows
Activate your conda environment
conda install -c anaconda tensorflow-gpu
This command would install TensorFlow v2.2.0 to your conda environment.
If you want the latest tf v2.4 then try using pip to install the specific version inside your conda environment
pip install tensorflow-gpu==2.4
Keras will automatically be installed with TensorFlow 2.0 verison. You can use Keras library with TensorFlow backend. If you want a specific version of Keras, you can always install it using pip
How can I set keras's backend to be MXNet?
I have found only this installation guide, but after I install keras by hand in this way, Anaconda does not recognize this installation.
In other words, this command:
KERAS_BACKEND=mxnet python -c "from keras import backend"
works only in the "keras" installation folder.
Therefore, I can not use keras in a Jupyter Notebook, for example.
Do you know another way to install keras in order to be compatible with mxnet (as it is for example on aws's AMIs) ?
You can install keras for a given Anaconda env by first activating that env and then calling
pip install -e .
in keras folder. In the guide that you included the link to, this command would replace
sudo python setup.py install
which installs it system wide.
So basically, I am fairly new to programming and using python. I am trying to build an ANN model for which I have to use Tensor flow, Theano and Keras library. I have Anaconda 4.4.1 with Python 3.5.2 on Windows 10 x64 and I have installed these libraries by following method.
Create a new environment with Anaconda and Python 3.5:
conda create -n tensorflow python=3.5 anaconda
Activate the environment:
activate tensorflow
After this you can install Theano, TensorFlow and Keras:
conda install theano,
conda install mingw libpython,
pip install tensorflow,
pip install keras,
Update the packages:
conda update --all
All these packages are installed correctly and I have check them with conda list.
However, when I am trying to import any of these 3 libraries (i.e. Tensor flow, Theano and Keras), it is giving me the following error:
Traceback (most recent call last):
File "<ipython-input-3-c74e2bd4ca71>", line 1, in <module>
import keras
ImportError: No module named 'keras'
Hi I have an solution try this if you are using Anaconda-Navigator
go to Anaconda Environment and search keras package and then install.
after install just type import keras in shell its working.
Have you tried using keras documentation
Install Keras from PyPI (recommended):
Note: These installation steps assume that you are on a Linux or Mac environment. If you are on Windows, you will need to remove sudo to run the commands below.
sudo pip install keras
If you are using a virtualenv, you may want to avoid using sudo:
pip install keras
from: https://keras.io/
Now you need to have Tensorflow installed and then write, for example:
import tensorflow as tf
...
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(12, input_dim=8, activation='relu'))
model.add(tf.keras.layers.Dense(8, activation='relu'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
...
Works for Tensorflow version: 2.4.1.
Or just type:
import tensorflow as tf
from tensorflow import keras
...
Try
import sys
print(sys.path)
and see if your anaconda site-packages folder is in the list.
It should be something like WHERE_YOU_INSTALLED_ANACONDA\anaconda3\envs\ENVIRONMENT_NAME\lib\python3.5\site-packages
If the path setting is correct, then try listing the folder content, and see if Keras, TensorFlow and Theano are in this folder.
I ran into a very similar issue after switching computers and downloading the latest Anaconda, which comes with python 3.6. It was no problem to install python 3.5 in its own environment, and install keras to this environment, but import keraskept failing.
My inelegant solution (assuming you've already got tensorflow/theano/cntk working fine in your global environment)?
Move the keras folder installed to Anaconda3/envs//Lib/site-packages/keras to Anaconda3/Lib/site-packages/keras. Now import keras gives a depreciation warning when run from a jupyter notebook launched via start menu, but it does work, and correctly returns the backend keras is running on.
I spent the whole day to install Keras, tried all the available methods online, almost dying. But I still cannot import keras.
(1). After using conda install or pip install, and delete the "1 > null > 2&1" ... I activated in conda prompt by activating tensorflow_cpu, it doesn't work anyway.
(2). Then checked the keras, and print os.path(), no virtual environment inside. I got so braindead, just copied all the keras data file from virtual environment env, and put into the "C:\Users\Administrator\Anaconda3\Lib\site-packages".
(3). Now, tensorflow and keras work well.
Click Update Index and then try searching for Keras again.
I have the same problem with:
conda 4.13.0
tensorflow 2.6.0
Note: We should not have to install Keras separately, as it ships with Tensorflow, starting with Tensorflow 2.0.
Symptoms:
Keras import (from tensorflow import keras) does not return an error, BUT any further reference to Keras does throw "ModuleNotFoundError", e.g. the following statements fail:
print(keras.__version__)
from keras import Sequential
I still don't have a direct solution for this, this is more of a workaround, but here it is:
Import ANY class from Keras JUST ONCE using full top-down import syntax AND instantiate it
Import Keras (now "for real")
E.g.:
from tensorflow.keras.layers import Dense
layer = Dense(10)
from tensorflow import keras
Now the following statements should work:
print(keras.__version__)
model = keras.models.Sequential()
This looks like some sort of lazy module loading gone wrong.
A direct and simple way to fix it is as below,
#uninstall keras and tensorflow
pip uninstall keras
pip uninstall tensorflow
#Now install keras and tensorflow for required version with dependencies.
pip install keras==2.2.4
pip install tensorflow==1.13.1
Always make sure that you install right version of tensorflow which supports that keras version as well, else you may end up in trouble again. By the way , the above fix worked for me.
I solved this problem by running one of the following in the terminal according to anaconda website.
To install this package (keras) with conda run one of the following:
conda install -c conda-forge keras conda install -c
conda-forge/label/broken keras conda install -c
conda-forge/label/cf201901 keras conda install -c
conda-forge/label/cf202003 keras
If you never use conda before you can check anaconda.
A direct and simple way to fix it is as below, #uninstall keras and tensorflow
py -3 -m pip uninstall keras
py -3 -m pip uninstall tensorflow
#Now install keras and tensorflow for required version with dependencies.
py -3 -m pip install keras
py -3 -m pip install tensorflow
the above fix worked for me.
If you are sure that you ran pip install keras at the command line, ensure that you use the small letter 'k' instead of the Capital Alphabet. I had a similar error message.
These are some simple steps to install 'keras' simply using the Anaconda Navigator:
Launch Anaconda Navigator. Go to the Environments tab.
Select ‘Not installed’, and type in ‘tensorflow’.
Then, tick ‘tensorflow’ and do the same for ‘keras’.
Click on ‘Apply’. The pop-up window will appear, go ahead and apply.
This may take several minutes.
Done.
This tutorial will guide you more graphically: https://www.freecodecamp.org/news/install-tensorflow-and-keras-using-anaconda-navigator-without-command-line/
Remember to launch spyder in the environment or activate it in line command (conda activate [my_env]. afater that, execute your script python.
Try to import keras library from its reference parent which means import tensorflow.keras
I'm having trouble installing the Keras library for Python 3.6. Whenever I try to install Keras, it is throwing an error and when I searched on the internet, Keras had been released for up to Python 3.5. Does anyone have a solution for this?
Follow this method if you have Anaconda and Python version 3.6.
First, create a new conda environment,
conda create -n keras python=3.5
Now activate it,
source activate keras
and install Keras,
conda install keras
Test if it works,
$ python
>>>import keras
You will get the following message if it was successful:
Using TensorFlow backend.
Click here to see Mike Müller's answer
I used sudo pip install keras to download.
I have both python 2.7 and 3.6 installed on my Mac. I used pip -V to check my python version of installation. Probably you used invalid version of python to download.
Screenshot of the install being done on my computer:
Follow the below steps , Tensorflow dosnt support py3.7 as of now , so 3.6 is better , I recommend using environment , (venv , conda(preferred) ),
For conda
conda create -n keras python=3.6
source activate keras
conda install tensorflow keras
#for faster installation
pip install keras
For virtualenv
virtualenv -p python3 keras
source keras/bin/activate
pip install keras tensorflow numpy
Try the following at a command prompt:
pip install --upgrade tensorflow
pip install --upgrade keras
Also, refer the following link for more detail:
https://www.tensorflow.org/install/pip