Skip to content

Instantly share code, notes, and snippets.

@victor-shepardson
Last active September 10, 2022 16:09
Show Gist options
  • Save victor-shepardson/3eb67c3664cde081a7e573376b1b0b54 to your computer and use it in GitHub Desktop.
Save victor-shepardson/3eb67c3664cde081a7e573376b1b0b54 to your computer and use it in GitHub Desktop.
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory

Code

https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4

Setup

I'm using Ubuntu 16.04 with a GTX 1060

install CUDA

I had to use the .run to get CUDA 8 back when Pascal was new, for some reason lost to time. The apt package probably works fine these days.

set PATH, CUDA_HOME, LD_LIBRARY_PATH appropriately.

install Anaconda

download for python3.6, run the script.

https://www.continuum.io/downloads

The following assumes you set Anaconda as the default python; if not, replace python and pip with e.g. ~/anaconda3/bin/python

install glumpy

sudo pip install glumpy

http://glumpy.readthedocs.io/en/latest/index.html

build pytorch

(I had to because of old AMD CPU, otherwise conda package is probably fine)

https://github.com/pytorch/pytorch#from-source

build pycuda

Necessary for opengl interop, also possibly for some CUDA locations.

clone or untar pycuda, cd in

get root with current environment: sudo -E su -p

python configure.py --cuda-root=$CUDA_HOME --cuda-enable-gl

python setup.py make

python setup.py install

https://wiki.tiker.net/PyCuda/Installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment