[PYTHON] Install pycuda on Windows10

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

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

Install pycuda on Windows10
Install pygraphviz on Windows 10
Install Chainer 1.5.0 on Windows
Install Numpy on virtualenv on Windows
Install watchdog on Windows + Python 3.3
Install Win-Kex (kali-linux) on Windows 10.
Install Chainer 1.6 (GPU) on Windows 7.
[Python] [Chainer] [Windows] Install Chainer on Windows
Pip install --ugrade pip fails on Windows
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Build and install OpenCV on Windows
Install Pytorch on Blender 2.90 python on Windows
How to install pycrypto on Windows
Install Python development environment on Windows 10
Install PyStan on Windows without Anaconda
How to install music 21 on windows
Install easy_install and pip on windows
Python on Windows
Install easy_install (Windows)
[Kivy] How to install Kivy on Windows [Python]
Install wsl2 and master linux on windows
How to install richzhang / colorization on Windows 10
Install mecab on Marvericks
Install Tensorflow on Mac
Install TensorFlow on Ubuntu
Install python on WSL
Install Faiss on CentOS 7
Install pyenv on mac
Install and run Python3.5 + NumPy + SciPy on Windows 10
Install Python3, numpy, pandas, matplotlib, etc. on Windows
Install Python on Pidora.
Install mongodb on termux
Install Scrapy on python3
Pylint on Windows Atom
Install docker on Fedora31
Linux (WSL) on Windows
Install numba on CentOS 7.2
Install Ansible on Mac
Install Python on Mac
Install Python 3 on Mac
Install Plone (4.3.6) on MacOSX (10.10.3)
Install PySide2 on Ubuntu
Install Python3.4 on CentOS 6.6
Use pyvenv on Windows
How to quickly install h5py on Windows 10 [Unofficial]
Install gensim on Marvericks
Install JModelica on Ubuntu
Anaconda on Windows Terminal
python basic on windows ②
Install numpy on Marvericks
Install enebular-agent on Chromebook
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Build TensorFlow on Windows
Install aws-cli on MacPorts
Try FEniCS on Windows!
Build XGBoost on Windows
Use Ansible on Windows
Install Docker on AWS