Skip to content

Htnek/environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 

Repository files navigation

How to get Tensorflow working with Anaconda on Windows

conda install cudatoolkit==10.1.243 cudnn tensorflow-gpu

Adding NVIDIA GPU support for Ubuntu 18.04

This is from https://www.tensorflow.org/install/gpu

Add NVIDIA package repositories

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update

Install NVIDIA driver

sudo apt-get install --no-install-recommends nvidia-driver-450

Reboot. Check that GPUs are visible using the command:

nvidia-smi
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt-get update

Install development and runtime libraries (~4GB)

sudo apt-get install --no-install-recommends \
    cuda-11-0 \
    libcudnn8=8.0.4.30-1+cuda11.0  \
    libcudnn8-dev=8.0.4.30-1+cuda11.0

Install TensorRT. Requires that libcudnn8 is installed above.

sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0 \
    libnvinfer-dev=7.1.3-1+cuda11.0 \
    libnvinfer-plugin7=7.1.3-1+cuda11.0

Install Anaconda

Download installer from: https://www.anaconda.com/download/#linux

Include the bash command regardless of whether or not you are using Bash shell.
If you did not download to your Downloads directory, replace ~/Downloads/ with the path to the file you downloaded.

bash ~/Downloads/Anaconda3-YYYY.MM-Linux-x86_64.sh

Scroll to the bottom of the license terms and enter “Yes” to agree.
Accept the default install location.
The installer prompts “Do you wish the installer to initialize Anaconda3 by running conda init?” Choose “yes”.
Close and open your terminal window for the installation to take effect, or you can enter the command:

source ~/.bashrc

To run conda from anywhere without having the base environment activated by default, use:

conda config --set auto_activate_base False

Create the environment tf2

git clone https://github.com/Htnek/environment.git
conda env create -f environment.yml
conda activate tf2

Registering kernel

python -m ipykernel install --user --name=python3

Removing unwanted-kernel

Find it with:

jupyter kernelspec list

Remove it with:

jupyter kernelspec uninstall unwanted-kernel

Starting Jupyter Notebook

jupyter notebook

Update environment tf2

conda env update --file environment.yml  --prune

Removing environment

Show name of environment

conda info --envs

Removal of environment

conda remove --name name_of_environment --all

Test if GPU is available

Start a terminal

conda activate tf2

Start python

python

In python write:

import tensorflow as tf

In python write:

tf.config.list_physical_devices('GPU')

If all goes well you will see:

Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

How to watch GPU usage

watch -n 1 nvidia-smi

About

How to set up Anaconda environment on Ubuntu 18.04 with NVIDIA GPU support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published