Skip to content

Instantly share code, notes, and snippets.

@kastnerkyle
Forked from victor-shepardson/pytorch-glumpy.md
Created March 4, 2020 22:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastnerkyle/f0ca3859c9b2dffb8320dc57d784079c to your computer and use it in GitHub Desktop.
Save kastnerkyle/f0ca3859c9b2dffb8320dc57d784079c 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