I bought GTX1070, so I decided to try CUDA with python and prepared the environment, but I was surprised. Most of my installation notes have only letters, but if it helps.
--Environment
--Installation
[Anaconda 4.1.1 For Windows] (https://www.continuum.io/downloads#windows)
[Visual Studio Community 2013 with Update 5] (https://www.visualstudio.com/ja-jp/downloads/download-visual-studio-vs.aspx) --After installation, add "C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ bin" to the first environment variable PATH
When the CUDA Toolkit will support GTX1070 Graphics Card??? --Reinstall the latest version of the graphics driver according to the above
pycuda is installed with pip.
pip install pycuda
When I run the test code, I get a UnicodeDecodeError, so add the following code around line 264 of compiler.py by referring to here.
Anaconda3\lib\site-packages\pycuda\compiler.py
...
self._check_arch(arch)
if options is not None:
options.extend(["-Xcompiler","/wd 4819"])
else:
options = ["-Xcompiler","/wd 4819"]
cubin = compile(source, nvcc, options, keep, no_extern_c,
arch, code, cache_dir, include_dirs)
...
Confirmed operation with Test code.
test_pycuda.py
import pycuda.gpuarray as gpuarray
import pycuda.driver as cuda
import pycuda.autoinit
import numpy
a_gpu = gpuarray.to_gpu(numpy.random.randn(4,4).astype(numpy.float32))
a_doubled = (2*a_gpu).get()
print (a_doubled)
print (a_gpu)
The execution result is as follows. I haven't measured the time, but it seems to be working.
[[ 0.06258085 3.00050306 -2.16977096 -1.87397981] [-2.13656282 4.49329472 0.04928281 3.36462641] [-0.23879284 -2.65320969 -0.87821233 0.39281949] [ 0.31394795 -0.32421556 0.16610235 2.44501066]] [[ 0.03129042 1.50025153 -1.08488548 -0.9369899 ] [-1.06828141 2.24664736 0.0246414 1.6823132 ] [-0.11939642 -1.32660484 -0.43910617 0.19640975] [ 0.15697397 -0.16210778 0.08305117 1.22250533]]
By the way, the reason I got stuck was completely my mistake
--I have installed CUDA Toolkit 7.5 which is not compatible with GTX1070 (?) --At first, both python 2.7 series and 3.5 series were installed and I was confused. (After all, 2.7 series is once uninstalled)
Recommended Posts