Coder Social home page Coder Social logo

nvidia-cuda-tensorflow-installation's Introduction

Nvidia-CUDA-Tensorflow-installation

Install nvidia driver

For debian based:

You can check whether your computer has an NVIDIA GPU installed or not. Open the terminal and type

lspci | egrep 'VGA|NVIDIA'

NVIDIA drivers are available in the official contrib and non-free package repositories of Debian 11. To enable the contrib package repository, run the following command:

sudo apt-add-repository contrib
sudo apt-add-repository non-free

To update the APT package database, run the following command:

sudo apt update

Install nvidia-driver:

sudo apt install nvidia-driver
sudo reboot

For arch based:

For checking has GPU or not:

lspci | egrep 'VGA|NVIDIA'

And run this commanlines:

sudo pacman -Syu

Install git and clone this:

sudo pacman -S git
git clone https://gitlab.com/XavierEduardo99/nvidia-drivers-arch-linux-installer

Enter this directory:

cd nvidia-drivers-arch-linux-installer

If your kernel linux:

sudo sh install-nvidia.sh

If your kernel is linux-lts:

sudo sh install-nvidia.sh --lts

and reboot system

Install conda

Just run this commands in your terminal:

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

Follow the instruction from offical site.

Install cuda and cudnn for tensorflow

Create a virtual environment for your TensorFlow project and activate it.

conda create --name tf-gpu python=3.9
conda activate tf-gpu

Install required packages and libraries:

conda install -c conda-forge cudatoolkit=11.8.0
pip install nvidia-cudnn-cu11==8.6.0.163

Configure the system paths.The system paths will be automatically configured when you activate this conda environment.

mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh

LIFEHACK! If you want use cuda and cudnn without activating conda try this steps. WARNING!!If you can't fix after system crash, i don't recommend do this. If you believe in yourself so much, then let's start. Activate cuda installed environment:

conda activate tf-gpu

View cuda path:

python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"

Copy this path and run command.Replace path/to/cuda with copied path. WARNING copy directory path not file path!!!:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib/:path/to/cuda/lib'

Well done! You are set cuda path.

If when open new terminal tensorflow don't see GPU. Add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib/:path/to/cuda/lib' to .bashrc file.

Install tensorflow

conda activate tf-gpu
pip install --upgrade pip
pip install tensorflow==2.12.*

If all this steps doing well following command print GPU list:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Good luck

nvidia-cuda-tensorflow-installation's People

Contributors

wolfman1219 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.