Skip to content

Instantly share code, notes, and snippets.

@gu-ma
Forked from victor-shepardson/pytorch-glumpy.md
Created January 21, 2021 16:11
Show Gist options
  • Save gu-ma/3afa841a4dced4b128ccb186931ca731 to your computer and use it in GitHub Desktop.
Save gu-ma/3afa841a4dced4b128ccb186931ca731 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