Install CUDA Accelerate for Anaconda Python

The install procedure is similar for Mac, Linux, and Windows. Before starting GPU work (in any programming language) realize these general caveats:

  • I/O heavy workloads are generally less suitable for GPU
  • Consumer GPUs (GeForce) are > 10x slower than workstation class (Tesla, Quadro)

Prereqs

You must have a discrete Nvidia GPU in your laptop or desktop. Check for existence of an Nvidia GPU in your computer by:

lspci | grep -i nvidia

a blank response means an Nvidia GPU is not detected.

If you have have a Compute Capability 2.x Fermi GPU, you can fallback to Nvidia Toolkit 8.5.

Install

  1. Download Nvidia Toolkit 9, choosing → Linux → x86_64 → Ubuntu (pick version ≤ your install) → deb(network) and download the base installer
  2. Install CUDA Toolkit, from Linux Terminal:
    dpkg -i cuda-repo-*.deb
    
    apt update 
    apt install cuda
    
  3. Install Anaconda Accelerate. Setup a distinct conda environment for Cuda, since it requires specific module versions (some of which are not the latest).
    conda update conda
    
    conda create -n cuda
    conda activate cuda
    
    conda install accelerate
    

Test

These commands are issued within Python.

import numba.cuda.api,numba.cuda.cudadrv.libs

numba.cuda.cudadrv.libs.test()

numba.cuda.api.detect()

Examples

Notes

  • Even if you already have Continuum Accelerate (formerly NumbaPro) for Anaconda Python installed, it won’t work unless you have an adequate GPU with the CUDA drivers installed.
  • Try fixing error about having gcc too new by switching gcc version.

Tags: , ,

Categories:

Written by Michael Hirsch, Ph.D. //

Comments