Menu Close

How to Install anaconda + Keras/ Tensorflow (Ubuntu) / Pytorch

Recently, many times of environment installations push me to consider of writing a tutorial for saving time. In this tutorial, I would like to make a very quick and straightforward guideline that can lead most of us to start an enjoyable trip of deep learning.   We assume you’ve already installed CUDA.

Need to install Nvidia drivers: http://www.linuxandubuntu.com/home/how-to-install-latest-nvidia-drivers-in-linux

Step 1: download and install  Anaconda

Go to https://www.anaconda.com/download/

a) choose your system from the RED rectangle  Here, I choose Ubuntu (Linux)

b) get the downloading link from the BLUE rectangle by right click

c) wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh

This command line will start to download the anaconda installation package.

d) bash Anaconda-latest-Linux-x86_64.sh 

This command line will start installing.  Note: replace “latest” with the version of anaconda, in this case: bash Anaconda3-5.2.0-Linux-x86_64.sh

Note: the answers to all questions during installation are Yes except for the last question:

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]

>>> no

Step2: create one conda environment

a) cd ananconda3/bin

export PATH=/location/anaconda3/bin:$PATH In my case:export PATH=/home/pengliu/anaconda3/bin:$PATH

b)

conda create -p /location/yourenvname python=x.x

Note: if there are multiple users creating their own envs separately, please make sure the name of each env is unique.  Otherwise, conflicts may occur.

In my case :  conda create -p /home/pliu/pliupy3 python=3.6

Step3: Activate your new environment

             source activate /location/pliupy3

  Step4:

conda install tensorflow-gpu 
conda install -c nvidia cuda-toolkit
conda install -c nvidia cuda-toolkit=10.1.168

Step5: conda install keras

Step6: install other packages

conda install numpy

conda install tqdm

conda install pillow

Now, the installation work has been done and it should work well in most of the cases.

To test the environment:

(pliupy3) user@Server:~/anaconda3/bin$ python  

Press ENTER key

>>>import tensorflow as tf

>>>print(tf.__version__)

>>>1.12.0

To install Pytorch

PyTorch

On Linux:

conda install pytorch torchvision -c pytorch
conda install -c anaconda scikit-image
conda install scikit-learn

pip install python-gist
conda install seaborn

conda install altair
conda install altair_saver
pip3 install torchsampler
pip3 install torchsummary
conda install -c conda-forge opencv
conda install -c conda-forge pytorch-gpu

Others

Use pip like so:

 

The requirements.txt contains :

pip3 install  click
pip3 install  scipy
pip3 install pytables pip3 install  pytorch pip3 install  batchup


GLIBCXX_3.4.20 not found

sudo apt-get install libstdc++6
sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update
sudo apt-get upgrade


GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time referenc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/anaconda3/lib

Conda: command not found

Can not use conda in terminal after installation

find the solution here

#just redirect it

for Anaconda 2 :

  1. export PATH=~/anaconda2/bin:$PATH

for Anaconda 3 :

  1. export PATH=~/anaconda3/bin:$PATH

How to change default Anaconda python environment

https://stackoverflow.com/questions/28436769/how-to-change-default-anaconda-python-environment

What is the step-by-step procedure to fix the “The following packages have unmet dependencies”?

ImportError: /lib64/libm.so.6: version `GLIBC_2.23′ not found

This is due to the python version: downgrade it to python 3.6.8 by conda install python==3.6.8

1type’ as a synonym of type is deprecated; in a future version of numpy

This is due to numpy version. Downgrade it to 1.16