环境:

  • Ubuntu 14.04
  • 依赖项 Numpy

<h2>1. PyCUDA 安装</h2>

<h4>1.1 直接安装</h4>

sudo apt install python-pycuda

<h4>1.2 源码安装:</h4>

  • Step 1 下载并解压 PyCUDA
$ wget http://pypi.python.org/pypi/pycuda
$ tar xfz pycuda-VERSION.tar.gz
  • Step 2 编译PyCUDA
$ cd pycuda-VERSION # if you're not there already
$ python configure.py --cuda-root=/where/ever/you/installed/cuda
$ su -c "make install"

<h2>2. PyCUDA 测试</h2>

  • e.g. 1
$ cd pycuda-VERSION/test
$ python test_driver.py

输出 OK 即成功.

  • e.g. 2
$ cd pycuda-VERSION/examples
$ python test_demo.py
  • e.g. 3
import pycuda.autoinit
import pycuda.driver
free_bytes, total_bytes = pycuda.driver.mem_get_info() # 查询当前显卡的总显存,可用显存

<h2>3. 文档</h2>

官方文档

Last modification:October 9th, 2018 at 09:31 am