step0~step3 follow the instruction in https://wiki.tiker.net/PyCuda/Installation/Linux/Ubuntu
step4 (for python3.5): $sudo apt-get install build-essential python3-dev python3-setuptools libboost-python-dev libboost-thread-dev
Download PyCUDA and unpack it: $tar xzvf pycuda-VERSION.tar.gz
$cd pycuda-VERSION
$ ./configure.py --python-exe=/usr/bin/python3 --cuda-root=/usr/local/cuda --cudadrv-lib-dir=/usr/lib/x86_64-linux-gnu --boost-inc-dir=/usr/include --boost-lib-dir=/usr/lib --boost-python-libname=boost_python-py35 --boost-thread-libname=boost_thread --no-use-shipped-boost
$ make -j 4
$ sudo python3 setup.py install
step5 (test installzation): $ cd examples/
$ python3 demo.py
如果在运行使用到pycuda时,出现 找不到nvcc的问题,但是,在终端通过 nvcc -V 或者 which nvcc可以找到nvcc的相关信息时,我采用以下方法解决了此问题:
sudo gedit /etc/enviroment, 将所安装的cuda8.0的路径(我的是 usr/local/cuda-8.0/bin)加到path后面,重启机器!
testing output is :
[[-0.73402965 0.27021709 0.02252972 -0.13197117]
[ 0.33812249 0.486314 -1.02830327 -0.07789359]
[ 0.75662965 0.6742726 -0.92978919 -0.70925355]
[-1.74797106 1.41699934 0.33079711 -1.71537197]]
doubled with kernel:
[[-1.4680593 0.54043418 0.04505945 -0.26394233]
[ 0.67624497 0.972628 -2.05660653 -0.15578718]
[ 1.51325929 1.34854519 -1.85957837 -1.4185071 ]
[-3.49594212 2.83399868 0.66159421 -3.43074393]]
doubled with InOut:
[[-1.4680593 0.54043418 0.04505945 -0.26394233]
[ 0.67624497 0.972628 -2.05660653 -0.15578718]
[ 1.51325929 1.34854519 -1.85957837 -1.4185071 ]
[-3.49594212 2.83399868 0.66159421 -3.43074393]]
original array:
[[-0.05362955 0.38353631 1.14744794 2.10718703]
[-0.49023584 0.39153752 0.37595326 -0.50278574]
[-0.20742868 -0.29073218 -0.43260652 -0.75614166]
[ 0.73224729 -0.35651347 -0.74725002 -1.64894199]]
doubled with gpuarray:
[[-0.10725911 0.76707262 2.29489589 4.21437407]
[-0.98047167 0.78307503 0.75190651 -1.00557148]
[-0.41485736 -0.58146435 -0.86521304 -1.51228333]
[ 1.46449459 -0.71302694 -1.49450004 -3.29788399]]