Skip to content

Instantly share code, notes, and snippets.

@VioletVivirand
Last active November 1, 2022 00:27
Show Gist options
  • Save VioletVivirand/9fd44c325755417f4d0a424e3fad7462 to your computer and use it in GitHub Desktop.
Save VioletVivirand/9fd44c325755417f4d0a424e3fad7462 to your computer and use it in GitHub Desktop.
Python venv and Nvidia Driver installation instruction (https://bit.ly/2E3H9Rk)

Nvidia GPU Computing Prerequisites

Step-by-step

  1. Nvidia Driver
  2. CUDA (Compute Unified Device Architecture)
  3. cuDNN (NVIDIA CUDA® Deep Neural Network library)
  4. Install tensorflow-gpu

Nvidia Driver

Visit NVIDIA download drivers page, choose the right hardware and download, open the installer and finish it.

CUDA

Visit Tensorflow GPU Support page to confirm the version we gonna install.

Then visit CUDA Toolkit Download page, Choose the OS, Architecture, Distribution, Version directly if web gonna install the latest version, otherwise visit Legacy Releases page to get the installer.

Execute the executable file and finish it step-by-step.

References:

cuDNN

Visit Tensorflow GPU Support page to confirm the version we gonna install.

Visit Download cuDNN page, register, login, and download the right version. For legacy version, please visit Archived cuDNN Releases page.

Unarchive the downloaded file and move them into the right path.

Reference: cuDNN Installation Guide

Windows

  • Copy cudnn64_7.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
  • Copy cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include
  • Copy cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64

Mac OS

# Unarchive
$ tar -xzvf cudnn-9.0-osx-x64-v7.tgz

# Copy files
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib/libcudnn* /usr/local/cuda/lib
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib/libcudnn*

# Set environment variables
$ export  DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH

Linux

[TODO]

Install Tensorflow-GPU

# Pip
pip install tensorflow-gpu

# Anaconda
conda install tensorflow-gpu

Verify

Virtual Environment

Python 3 venv

Docs: venv — Creation of virtual environments

Windows

# Creation
# Warning: Replace "python3" command if you need to use
# another command to launch Python's interpreter
c:\>python3 -m venv <path>

# Launch
c:\<path>\Scripts\activate.bat

# Deactivate
c:\deactivate

Reference: https://docs.python.org/3/library/venv.html#creating-virtual-environments

Mac OS

# Creation
# Warning: Replace "python3" command if you need to use
# another command to launch Python's interpreter
python3 -m venv <path>

# Launch
source <path>/bin/activage

# Deactivate
deactivate

Reference: https://docs.python.org/3/library/venv.html#creating-virtual-environments

Anaconda

# Creation
conda create --name <name>
# Create with specific Python version
conda create -n <name> python=3.5
# Create with specific Python version and Packages
conda create -n <name> python=3.4 scipy=0.15.0 astroid babel

# Activate
## Linux, Mac OS
source activate <name>
## Windows
activate <name>

# Deactivate
## Linux, Mac OS
source deactivate
## Windows
deactivate

Reference: https://conda.io/docs/user-guide/tasks/manage-environments.html

Pipenv

Docs: https://github.com/pypa/pipenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment